你管视频api,停止视频

时间:2016-11-08 12:14:52

标签: javascript jquery html youtube

如何让这项工作适用于多个视频,我只能使用一个视频

  1. 包括:

    <script type="text/javascript" src="http://www.youtube.com/player_api"></script>
    
  2. 添加youtube iframe:

    <iframe id="player" src="http://www.youtube.com/embed/YOURID?rel=0&wmode=Opaque&enablejsapi=1" frameborder="0"></iframe>
    
  3. 魔术时间:

    <script>
        var player;
        function onYouTubePlayerAPIReady() {
            player = new YT.Player('player');
        }
        // so on jquery event or whatever call the play or stop on the video.
        // to play player.playVideo();
        // to stop player.stopVideo();
    </script>
    

0 个答案:

没有答案