2016-12-30 158 views
0

如何停止YouTube視頻加載,一旦我暫停它?如何停止加載嵌入的YouTube視頻後,暫停它

一旦我暫停視頻,在視頻加載進度條也應該停止。

<iframe width="560" height="315" src="https://www.youtube.com/embed/Ggh_y-33Eso" frameborder="0" allowfullscreen></iframe> 
+1

刷新iframe的來源,雖然這是不好的,或者您使用iframe中這樣使用iframe API –

+0

? http://codepen.io/anon/pen/VmogpK – 0x736a64

+0

是我使用的iframe僅 – user7357089

回答

0
You may want to review through the Youtube JavaScript API Reference docs. 

When you embed your video(s) on the page, you will need to pass this parameter: 

http://www.youtube.com/v/VIDEO_ID?version=3&enablejsapi=1 
If you want a stop all videos button, you can setup a javascript routine to loop through your videos and stop them: 

player.stopVideo() 
This does involve keeping track of all the page IDs for each video on the page. Even simpler might be to make a class and then use jQuery.each. 

$('#myStopClickButton').click(function(){ 
    $('.myVideoClass').each(function(){ 
    $(this).stopVideo(); 
    }); 
}); 
+0

我不明白,我想停止加載時,我暫停YouTube視頻嵌入視頻 – user7357089

相關問題