php - 当iframe嵌入式视频播放,暂停,缓冲时如何显示警报

标签 php jquery youtube youtube-api

当我们使用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/

相关文章:

php - 使用 predis 包将缓存超时设置为 Codeigniter 中的一个键

ios - UIWebview中如何获取当前播放视频的url

javascript - JQuery 可拖动元素在 droppable.append(draggable) 上消失在 droppable 中

google-chrome - Youtube视频未在Chrome中显示,但在Firefox中显示

java - 通过在 Youtube API 上插入设置公共(public)统计信息

php - 让 composer update 从 git repo 获取最新版本

php - 无法向数据库插入新行

PHP在线/离线管理?

jQuery - $(some_element) 是否存在于 $(this) 和 $(this).closest(container) 之间?

jquery - 使用 jQuery 拖放的排序列表