JWPlayer 防止向前跳过,除非已经看过 [英] JWPlayer Prevent SKipping forward unless already watched

查看:19
本文介绍了JWPlayer 防止向前跳过,除非已经看过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 JWPlayer 5.4,它是使用 javascript API 在页面上设置的.

I'm using JWPlayer 5.4 and it's setup on the page using the javascript API.

我想做的是让用户可以通过搜索栏快进/快退,前提是他们已经播放了视频的那部分.

What I'd like to do is make it so that users can fastforward/rewing via the seek bar ONLY if they have already played that part of the video.

因此,如果用户是第一次观看视频,他们不能跳过当前位置,但是他们可以向前和向后搜索视频播放的位置.

So, if a user is watching the video for the first time they can't skip beyond the current position, however they can seek forward and back behind where the video played up until.

我正在努力处理 API onTime 事件等,以尝试计算数学以使其工作.

I'm struggling with the API onTime events etc. to try and work out the Math to make this work.

有谁知道如何做到这一点.

Does anyone know how this could be done.

谢谢

推荐答案

我不久前发现了这个,可能是在 JWplayer 论坛上.我想我添加了一些关于播放列表的内容.因此,以防万一您或其他人仍在寻找答案,请考虑添加以下内容:

I found this a while back, probably on the JWplayer forum. I think I added a bit about the playlist. So just in case you or others are still looking for an answer, consider adding stuff like:

var maxPlayPosition = 0.0;
var seeking = false;

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

这篇关于JWPlayer 防止向前跳过,除非已经看过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆