最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jwplayer seek() and onTime() to play bits of video - Stack Overflow

programmeradmin5浏览0评论

So I've been trying to manipulate my jwplayer which plays youtube videos with success but still encounter a bit of a problem.

I want my player to play from a "start time" and stop at en "end time". Those two values will be taken from two form inputs. So I went and wrote this little function which work quite well :

function timeControl(start, end) {
jwplayer().seek(start).onTime(function (event) {
    if(event.position >= end ) {
        this.stop();
    }
});

}

The thing is, if I run this function twice, the second time it will sometimes ignore the new parameters (for example if I set the start time at 3 seconds and end time at ten, if I run it again with the end time being 6seconds, it will work, but it won't if I start with end time at 6 and then at ten... )

Anybody has an idea of what's going on ? Anyway to reset the "onTime" property of the player without having to reload the player ?

Thanks in advance !

So I've been trying to manipulate my jwplayer which plays youtube videos with success but still encounter a bit of a problem.

I want my player to play from a "start time" and stop at en "end time". Those two values will be taken from two form inputs. So I went and wrote this little function which work quite well :

function timeControl(start, end) {
jwplayer().seek(start).onTime(function (event) {
    if(event.position >= end ) {
        this.stop();
    }
});

}

The thing is, if I run this function twice, the second time it will sometimes ignore the new parameters (for example if I set the start time at 3 seconds and end time at ten, if I run it again with the end time being 6seconds, it will work, but it won't if I start with end time at 6 and then at ten... )

Anybody has an idea of what's going on ? Anyway to reset the "onTime" property of the player without having to reload the player ?

Thanks in advance !

Share Improve this question asked Aug 5, 2012 at 12:15 CharleshaaCharleshaa 2,2383 gold badges21 silver badges25 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

I know this question is old, but I'm going to out on a limb and say that the problem simply might be that your generically referencing jwplayer, and not specifically referencing a jwplayer video instance.

<div id="aVideoObject">Loading the player...</div>

<script type="text/javascript">

    jwplayer("aVideoObject").setup({
        flashplayer: "player.swf",
        width: 450,
        height: 320
    });

    function timeControl(start, end) {
        jwplayer("aVideoObject").seek(start).onTime(function (event) {
            if(event.position >= end ) {
                this.stop();
            }
        });
    }
</script>

This implementation works for me

You can find START time and duration here:

JW_Player_Quick_Start_Guide.pdf [Mirror2]

发布评论

评论列表(0)

  1. 暂无评论