यूट्यूब के माध्यम से muting प्रदान नहीं करते यूआरएल पैरामीटर (http://code.google.com/apis/youtube/player_parameters.html देखें)।
आपको इसके लिए जावास्क्रिप्ट का उपयोग करना होगा। विवरण के लिए http://code.google.com/apis/youtube/js_api_reference.html देखें।
हालांकि, पेज ऊपर लिंक पर चेतावनी कृपया ध्यान दें:। "यूट्यूब जावास्क्रिप्ट प्लेयर API की निंदा 27 जनवरी, 2015 को घोषणा की गई थी यूट्यूब फ्लैश एम्बेड करता है भी अमान्य हो जाने के बारे में अधिक जानकारी के लिए प्रतिवाद नीति देखें। कृपया अपने अनुप्रयोगों को IFrame API पर माइग्रेट करें, जो बुद्धिमानी से जो भी एम्बेडेड प्लेयर - HTML() या Flash() - क्लाइंट का समर्थन करता है, का उपयोग कर सकते हैं। "
एचटीएमएल
<iframe class="youtube-player" id="player" type="text/html" src="http://www.youtube.com/embed/JW5meKfy3fY?wmode=opaque&autohide=1&autoplay=1&enablejsapi=1" frameborder="0"><br /></iframe>
कृपया ध्यान दें enablejsapi = 1 यूआरएल में।
जावास्क्रिप्ट
var player = iframe.getElementById('player');
player.mute();
अद्यतन
पिछला कोड कुछ मुद्दों था और वर्तमान एपीआई (playerVars वाक्य रचना गलत था) के साथ काम नहीं किया। यहां अद्यतन कोड है। आपको आवश्यक पैरामीटर के साथ आपको टिंकर करने की आवश्यकता हो सकती है।
<div id="player"></div>
<script>
// 1. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// 2. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '100%',
width: '100%',
playerVars: {
autoplay: 1,
loop: 1,
controls: 0,
showinfo: 0,
autohide: 1,
modestbranding: 1,
vq: 'hd1080'},
videoId: '1pzWROvY7gY',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
// 3. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
player.mute();
}
var done = false;
function onPlayerStateChange(event) {
}
function stopVideo() {
player.stopVideo();
}
</script>
स्रोत
2012-01-15 12:04:39
यह कहता है "iframe है परिभाषित नहीं"? – TIMEX
क्या आप मुझे बता सकते हैं कि क्या गलत है? http://jsfiddle.net/9RjzU/ धन्यवाद – TIMEX
मैंने सही कोड के साथ पहेली को अद्यतन किया। http://jsfiddle.net/9RjzU/3/ –