暂停JW播放器? [英] pause JW player?

查看:127
本文介绍了暂停JW播放器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个标签.

每个标签的滑块中都有两个视频. 问题是当我切换任何选项卡或单击任何单个视频时,其他所有视频都应暂停.

Each tab having two videos in slider. The problem is when I switch any tab or click any single video,all other should pause.

我可以收集所有id,然后循环使用stop().但是还有其他方法更干净,更简单吗??

I can collect all the ids and then loop over to use stop().But is there any other method that is much more cleaner and simpler.?

jwplayer('video_pub').stop(); //for 1 video..how can i do for all videos?

推荐答案

代替使用jwplayer().stop(),您可以使用jwplayer().pause()

Instead of using jwplayer().stop(), you can use jwplayer().pause()

为此,我最喜欢jwplayer().play(false).

来源: Jwplayer API

逻辑

仅获取具有所有标签的父视频包装器(因为 每个选项卡都有两个视频)...查找当前正在运行的jwplayer 播放并停止所有其他玩家.

just get the parent video wrapper which have all tab (since each tab has two video)... find jwplayer whiich is currently being played and stop all other players.

pauseMedia : function(playingMediaId) {
        $('#parent_video_wrapper').find('.jwplayer, object').each(function(){
            currentMediaId =$(this).attr('id');
            if( jwplayer(this).getState() == "PLAYING" || jwplayer(this).getState() == "BUFFERING" ) {
                if(currentMediaId != playingMediaId){
                    jwplayer(this).play(false);
                }
            }
        });
}

现在您可以将以上函数用作pauseMedia()或 pauseMedia(mediaId),两者都可以工作

now you can either use above function as pauseMedia() or pauseMedia(mediaId), Both will work

在视频设置中,如果您这样使用

In video Setup if you use it like this

jwplayer("video_"+videoId).setup({

events : {
onPlay : function (callback){
        var playingVideoId = 'video_'+videoId;
        pauseMedia(playingVideoId); 
       //pausing other simulatenously playing video in a tab

}
}
});

我认为上面的代码可以解决问题,只需尝试一下

I think above code might do the trick, just give it a try

这篇关于暂停JW播放器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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