Pradino
Pradino

Reputation: 462

jwplayer: using seek(), onTime() and stop() to play part of the video

I am using latest JW Player cloud hosted version.

I need to seek the video to start from certain position and stop at certain position using seek(), onTime() and stop().

jwplayer().onReady(function() { 
    jwplayer().seek(300).onTime(function(event) {
        if(event.position>330) {
            jwplayer().stop();
        }
    });
});

The video starts and stops with the above command, but if the user clicks on play button again, it starts from beginning instead of the time specified in seek().

I have advertisement associated with this video.

Any help!

Thanks

Upvotes: 1

Views: 5567

Answers (1)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

you could try using onBeforePlay() method, its fired just before playing, as:

jwplayer('player').setup({
        ......
    });
jwplayer().onBeforePlay(function(){ 
    jwplayer().seek(300); 
}); 

Upvotes: 6

Related Questions