如何在不重新启动当前播放视频的情况下加载播放列表 [英] How to load playlist without restart the current playing video

查看:105
本文介绍了如何在不重新启动当前播放视频的情况下加载播放列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们将新项目添加到播放列表时,请在播放视频时使用以下代码.

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?

任何建议将不胜感激.

推荐答案

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);
});

获取当前播放项目的位置,获取播放列表,将项目添加到播放列表,加载播放列表并使用seek和position变量继续播放.您可能必须获取当前播放项目的索引,以便在加载播放列表后返回到该项目,然后继续播放.

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.

这篇关于如何在不重新启动当前播放视频的情况下加载播放列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆