问题
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