当我们使用jquery单击特定的div内容时,我将其替换为相应的iframe。如何在动态加载iframe中的视频播放,暂停,缓冲时显示警报。
谁能告诉我如何解决此问题。
最佳答案
Try This Example :
<html>
<head>
<script src = "http://www.youtube.com/player_api"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8">
</head>
<body dir = "rtl">
<iframe id="player" width="640" height="360" src="http://www.youtube.com/embed/-cSFPIwMEq4" onload="floaded()" frameborder="0" allowfullscreen="">
</iframe>
<script>
//onYouTubePlayerAPIReady
var player;
function floaded(){
player = new YT.Player('player', {
videoId: '-cSFPIwMEq4',
events:
{
'onStateChange': function (event)
{
if (event.data == YT.PlayerState.PLAYING) { alert("Playing.."); }
else if (event.data == YT.PlayerState.PAUSED)
{ alert ("Paused.."); }
else
alert ("Buffering/Video Ended");
}
}
});
}
</script>
</body>
</html>
关于php - 当iframe嵌入式视频播放,暂停,缓冲时如何显示警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20760452/