我正在尝试在jwplayer开始播放之前获取视频的持续时间。我尝试在onReady事件回调中调用getDuration(),但它返回-1。当我在onPlay事件回调中调用getDuration()时,我得到了正确的值。有任何想法吗?
以下是我的代码:
以下是我的代码:
<video src="movie.mp4" id="video" width="800" height="600"></video>
<script type="text/javascript">
jwplayer ('video').setup ({
flashplayer: '/js/mediaplayer-5.10/player.swf',
width: 600,
height: 400,
events: {
onReady: function () {
var duration = this.getDuration();
alert ('ready, duration: ' + duration);
},
onPlay: function (state) {
alert ('play, duration: ' + this.getDuration());
}
}
});
</script>