现状: 在这里,在这里我按下一些视频。
问题:我试图阻止由JavaScript中的视频在Firebug的控制台:
player.stopVideo(playerid):Void [1] [2]
问:为什么上面的工作不是命令?
[1] 来源的部分“player.stopVideo():空隙”
[2]余从源看着playerid与萤火虫。
现状: 在这里,在这里我按下一些视频。
问题:我试图阻止由JavaScript中的视频在Firebug的控制台:
player.stopVideo(playerid):Void [1] [2]
问:为什么上面的工作不是命令?
[1] 来源的部分“player.stopVideo():空隙”
[2]余从源看着playerid与萤火虫。
您的视频请求瓦特/启用JSAPI,让你非常接近! 所有你需要的是嵌入播放器的有效参考。 检查你的页面显示您正在使用的“playerid”的HTML DOM元素的ID,以确定您的播放器。
例:
<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">
为了获得给玩家的引用,然后停止视频使用下面的代码:
var myPlayer = document.getElementById('playerid');
myPlayer.stopVideo();
下面的效果很好,测试WAMP的服务器上。 只需更换与要播放的视频的下面一行的11位ID。
http://www.youtube.com/v/***LpbzbyGjJGE***?enablejsapi=1&version=3&playerapiid=ytplayer
祝好运。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<a href="#" onclick="var myPlayer = document.getElementById('playerid'); myPlayer.pauseVideo();">Pause</a>
<a href="#" onclick="var myPlayer = document.getElementById('playerid'); myPlayer.playVideo();">Play</a>
<embed id="playerid" width="500px" height="400px" allowfullscreen="true" allowscriptaccess="always" quality="high" bgcolor="#000000" name="playerid" style="" src="http://www.youtube.com/v/LpbzbyGjJGE?enablejsapi=1&version=3&playerapiid=ytplayer" type="application/x-shockwave-flash">
</body>
</html>
因此,这是做的最快捷的方法!
打开开发人员选项
将鼠标悬停在YouTube播放按钮。
按Ctrl /命令+ Shift + C键
选择按钮
添加ID到它。
进入控制台,并运行以下
VAR X =的document.getElementById( '编号'); x.click();
而已!