Youtube embeded action when video ends

后端 未结 2 1745
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 00:15

I wonder if it is possible to make an action with youtube api when embeded video finishes. For example, in my web i start video on hover of one element, but i want video tu

相关标签:
2条回答
  • 2021-01-07 00:49

    I had wordpress and used in suchh steps: installed http://www.tikku.com/jquery-youtube-tubeplayer-plugin

    then add this code into page
    but change
    1) yoursite.com to yours
    2) alert("Hello"); to your another desired function;
    3) DkoeNLuMbcI to desired video id;

    <div id="youtube-player-container" style="float:right"> </div>
    <script type="text/javascript" src="http://yoursite.com/folder/jQuery.tubeplayer.min.js"></script>
    <script type="text/javascript">
    jQuery("#youtube-player-container").tubeplayer({
        width: 422, // the width of the player
        height: 285, // the height of the player
        allowFullScreen: "true", // true by default, allow user to go full screen
        initialVideo: "DkoeNLuMbcI?autoplay=1", // the video that is loaded into the player
        preferredQuality: "default",// preferred quality: default, small, medium, large, hd720
        onPlay: function(id){}, // after the play method is called
        onPause: function(){}, // after the pause method is called
        onStop: function(){}, // after the player is stopped
        onSeek: function(time){}, // after the video has been seeked to a defined point
        onMute: function(){}, // after the player is muted
        onPlayerEnded: function(){ alert("Hello"); },
        onUnMute: function(){} // after the player is unmuted
    });
    </script>
    
    0 讨论(0)
  • 2021-01-07 00:53

    use http://www.tikku.com/jquery-youtube-tubeplayer-plugin

    It makes everything easy. Once you have it set up, which shouldn't take long (there is an easy how-to), simply add this line to you player initiation:

        onPlayerEnded: function(){ // Do something here },
    

    This will do whatever you want after the player ends. There are also callbacks for when the player is paused, stopped, played, muted, unmuted, queued, and more

    Let me know if this works, or if you have trouble using the jquery plugin. It really is very helpful and easy!

    0 讨论(0)
提交回复
热议问题