繁体   English   中英

如何一次仅在页面中播放一个jwplayer而其他播放器停止播放

[英]How to play at time only one jwplayer in page while other players stop which are playing

如何停止页面中的所有jwplayer。 我的目标是一次只能播放一次jwplayer,容器ID是动态且唯一的。

我想要这样。

$('All_dynamic_player_container_ids').stop();$('dynamic_player_container_id').play();

Jwplayer代码如下

<?php while(list($display_name, $iId, $uid, $caption, $dt, $post_type, $ext,$blocked_user,$special,$stream_id, $comments, $likes, $userLiked , $exclusive) = mysql_fetch_array($result))
{ ?>
    <div class="post_image video_image<?php echo $iId ?>" id="video_image<?php echo $iId ?>"></div>
    <?php 
    echo '<script type="text/javascript">
    jwplayer("video_image'.$iId.'").setup({
    sources: [{
    file: "../vids/user/'.$uid.'-'.$iId.'.mp4", 
    },],
    image:"../imgs/user/'.$uid.'-'.$iId.'.jpg",
    logo: {
    file: "../images/logo/melogo.png",
    link: "http://'.SERVER.'",
    hide:true
    },
    modes: [{
    type: "html5"
    }],
    width: "100%",
    aspectratio: "16:9",
    autostart: false,
    });
    jwplayer("video_image'.$iId.'").onError ( function(event) {
    setTimeout(function()
    {
    jwplayer("player").play(true);
    },2000);
    }
    );
    </script>';

} ?>

在JavaScript中,您可以:

var myPlayers = $('.post_image div');
var numPlayers = myPlayers.length;
for (i=0;i<numPlayers;i++) {
    //this for loop will stop all the videos from playing
    jwplayer("'video_image'+i").stop();
}
//then you can play the video you want to play here

抱歉,我的php不好。 希望这会对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM