How can I stop a video with Javascript in Youtube?

前端 未结 3 1489
离开以前
离开以前 2020-11-29 03:52

Situation: here, where I pressed some video.

Problem: I try to stop the video by Javascript in the console of Firebug:

<         


        
3条回答
  •  渐次进展
    2020-11-29 03:59

    Your video is requesting w/ the JSAPI enabled, so you are very close! All you need is a valid reference to the embedded player. Inspecting your page revealed that you are using the HTML DOM element id of "playerid" to identify your player.

    Example:

    
    

    To obtain a reference to the player and then stop the video use the following code:

    var myPlayer = document.getElementById('playerid');
    myPlayer.stopVideo();
    

提交回复
热议问题