Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
500 views
in Technique[技术] by (71.8m points)

jquery youtube plugin - calling methods

I'm using the jQuery Youtube plugin to embed a youtube video and use some of the API methods with the video.

I have the following code:

<div id="player"></div>
<script type="text/javascript">
    jQuery("#player").tubeplayer({
        width: 600, // the width of the player
        height: 450, // the height of the player
        allowFullScreen: "true", // true by default, allow user to go full screen
        initialVideo: "VIDEO_ID", // 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
        autoPlay: true,
        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
        onUnMute: function(){}, // after the player is unmuted
        onPlayerEnded: function(){alert('ENDED')},
    });
</script>

This plays the video fine, but when the video has ended, I'd expect the onPlayerEnded() function to kick in and give me an alert('Ended'), which it doesn't.

Has anyone used this plugin before point me in any direction as to why this is the case?

Many thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

it works fine, may be a problem with you browser, try to use console.log instead of alert and check you console.

i put your code in a jsfiddle and it works http://jsfiddle.net/sabri/wHpmM/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...