2012-02-03 12 views
7

#t=1m49s सिंटैक्स को जोड़ने वाले YouTube वीडियो में एक विशिष्ट समय से लिंक करना संभव है।यूट्यूब iframe एम्बेड में विशिष्ट टाइम्स के लिए लिंक

क्या एम्बेड के उसी पृष्ठ पर लिंक होना संभव है जो वीडियो को वीडियो में अलग-अलग समय पर कूदता है?

<a href="">Link to 1 minutes 10 seconds</a> 
<a href="">Link to 3 minutes 4 seconds</a> 
<a href="">Link to 5 minutes 10 seconds</a> 
etc.. 

उत्तर

8

गोरान ने एपीआई संदर्भ पोस्ट किया है। मैं इसे जांचने की सिफारिश करता हूं। यद्यपि आप जो खोज रहे हैं उसके लिए यहां कुछ बुनियादी कोड दिया गया है। मैं मुख्य भागों टिप्पणी की है:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>  
<script> 
    //this function gets called when the player is ready  
    function onYouTubePlayerReady (playerId) { 
     ytplayer = document.getElementById("myytplayer"); 
     console.log(ytplayer); 
    } 
    //generic seekTo function taking a player element and seconds as parameters  
    function playerSeekTo(player, seconds) { 
     player.seekTo(seconds); 
    } 
</script> 

<div id="ytapiplayer"> 
    You need Flash player 8+ and JavaScript enabled to view this video. 
</div> 
<br/> 
<a href="#" onclick="playerSeekTo(ytplayer, 70); return false;">Link to 1 minutes 10 seconds</a> 
<a href="#" onclick="playerSeekTo(ytplayer, 90); return false;">Link to 1 minutes 30seconds</a> 
<a href="#" onclick="playerSeekTo(ytplayer, 110); return false;">Link to 1 minutes 50 seconds</a> 

अब js:

var ytplayer; 

$(document).ready(function() { 
    swfobject.embedSWF("//www.youtube.com/e/Py_IndUbcxc?enablejsapi=1&playerapiid=ytplayer &version=3", 
    "ytapiplayer", // where the embedded player ends up 
    "425", // width  
    "356", // height  
    "8", // swf version  
    null, 
    null, { 
     allowScriptAccess: "always" 
    }, { 
     id: "myytplayer" // here is where the id of the element is set 
    }); 

}); 

Here बेला है कि मैं बनाया है।

+0

मदद के लिए धन्यवाद! हालांकि, मैं इसे काम करने के लिए प्रतीत नहीं कर सकता। क्या आप शायद एक जेएसफिल्ड प्रदान कर सकते हैं? धन्यवाद! – bookcasey

+1

@bookcasey मैंने मूल उत्तर में कोड अपडेट किया है और एक कामकाजी पहेली शामिल है। अगर आपका कोई प्रश्न हैं, तो मुझे से पूछें। – sinemetu1

+1

जो लोग फ़ायरफ़ॉक्स का उपयोग करते हैं, बेवकूफ़ टूट नहीं जाता है, केवल अलग विंडो में परिणाम देखने पर वीडियो प्रदर्शित करता है। – lulalala

2

हालांकि मैं emdedded यूट्यूब वीडियो के साथ जावास्क्रिप्ट को लागू करने में कोई व्यक्तिगत अनुभव है, मैं जानता हूँ कि है कि यूट्यूब इस तरह के कार्यों को करने के लिए एक जावास्क्रिप्ट एपीआई की है। समारोह आप देख रहे हैं .seekTo()

http://code.google.com/apis/youtube/js_api_reference.html#seekTo

एक गंधा छोटे डेमो here के साथ है।

+0

आप iframe फ्लैश एम्बेड के बजाय एम्बेड उपयोग करना चाहते हैं, उसके लिए प्रलेखन https://developers.google पर है। कॉम/यूट्यूब/iframe_api_reference – DavGarcia

0

उपयोग ?start=xyz (सेकंड)

उदाहरण के लिए:

<iframe src="http://www.youtube.com/embed/vDFuzhnTegc?start=1778" width="420" height="235"></iframe> 
संबंधित मुद्दे