如何在 Youtube 中停止使用 Javascript 的视频?
情况:这里, 我按了一些视频.
问题:我尝试在 Firebug 的控制台中通过 Javascript 停止视频:
Problem: I try to stop the video by Javascript in the console of Firebug:
player.stopVideo(playerid):Void [1] [2]
问题:为什么上面的命令不起作用?
Question: Why does not the command above work?
[1] 来源部分player.stopVideo():虚"
[1] Source for the part "player.stopVideo():Void"
[2] 我用 Firebug 从源代码中查看了 playerid.
[2] I looked playerid with Firebug from the source.
推荐答案
您的视频正在请求启用 JSAPI,所以您非常接近!您所需要的只是对嵌入式播放器的有效引用.检查您的页面发现您正在使用playerid"的 HTML DOM 元素 ID 来识别您的播放器.
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.
例子:
<embed id="playerid" width="100%" height="100%" allowfullscreen="true" allowscriptaccess="always" quality="high" bgcolor="#000000" name="playerid" style="" src="http://www.youtube.com/apiplayerbeta?enablejsapi=1&playerapiid=normalplayer" type="application/x-shockwave-flash">
要获得对播放器的引用然后停止视频,请使用以下代码:
To obtain a reference to the player and then stop the video use the following code:
var myPlayer = document.getElementById('playerid');
myPlayer.stopVideo();
相关文章