How to load playlist without restart the current p

2020-03-30 07:00发布

When we add a new item to playlist use following code when a video is playing.

var playlist = jwplayer().getPlaylist();
    var newItem = {
        file: videoUrl,
        image: videoThumb,
        title: videoTitle
    };
    playlist.push(newItem);
    jwplayer().load(playlist);

when added item, the current video will be restart. But I wan't the video to be interrupt. Any one know how to do this?

Any suggestion will greatly appreciated.

标签: jwplayer
1条回答
姐就是有狂的资本
2楼-- · 2020-03-30 07:19
var curpos = jwplayer().getPosition();
var playlist = jwplayer().getPlaylist();
var newItem = {
    file: videoUrl,
    image: videoThumb,
    title: videoTitle
};
playlist.push(newItem);
jwplayer().load(playlist).onPlay(function () {
    jwplayer().seek(curpos);
});

Get position of the currently playing item, get playlist, add item to playlist, load playlist and resume playing using seek and position variable. You might have to get the currently playing item's index so after the playlist loads you go back to that item and then resume playing.

查看更多
登录 后发表回答