在移动浏览器的jwplayer中禁用向前搜索无效

时间:2013-07-03 11:27:02

标签: jquery jwplayer forward seek

以下是我的代码。

正向搜索功能已禁用,并且可在桌面浏览器中使用。但是,当它在移动浏览器中打开时,禁用正向搜索无效。

<div class="jw_player_box">
        <div id='my-video'></div>
<script type='text/javascript'>
 jwplayer('my-video').setup({
    file: 'jwplayer/2.mp4',
    flashplayer: "jwplayer/jwplayer.flash.swf",
    width: '360',
    height: '280',

});

var seek_okay = false;
var max_seen = 0.0; 
  jwplayer().onSeek(function (position, offset) {
    if (!seek_okay) {
      max_seen = Math.max(max_seen, position.position);
      if (position.offset > position.position) {
        seek_okay = true;
        setTimeout(function(){jwplayer().seek(Math.min(max_seen, position.offset))},100);
      }
    } else {
      seek_okay = false;
    }
 });
</script></div>  

请提出任何建议

2 个答案:

答案 0 :(得分:1)

尝试以下脚本。

        var maxPlayPosition = 0.0;
        var seeking = false;

        jwplayer().onTime(function(event) 
        {
            if (!seeking) 
            {
                maxPlayPosition = Math.max(event.position, maxPlayPosition); 
            }
        }).onPlaylistItem(function() 
        {
            maxPlayPosition = 0.0;
        }).onSeek(function (event) 
        {
            if (!seeking) 
            {
                if (event.offset > maxPlayPosition) 
                {
                    seeking = true;
                    setTimeout(function () 
                    { 
                        jwplayer().seek(maxPlayPosition); 
                    }, 100);
                }
            } 
            else 
            {
                seeking = false;
            }    
        });

原产地JWPlayer Prevent SKipping forward unless already watched

答案 1 :(得分:0)

这对我有用:

var position = 0;

jwplayer().on('time', function(e) {

   var positionDiff = e.position - position;

   if (positionDiff > 1) {
       jwplayer().seek(position);
   } else {
       var position = e.position;
   }
});

如果您转发视频,则positionDiff将大于1,因此我将视频返回到之前的位置。