How to load playlist without restart the current playing video

只谈情不闲聊 提交于 2019-12-01 09:50:36

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/11183926/how-to-load-playlist-without-restart-the-current-playing-video

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!