2014-09-25 57 views
0

我正在使用MediaElement.js並需要其他玩家在另一個玩家開始時停止播放。 這個問題以前已經問過,但我對如何應用這段代碼有點困惑。 我看到其他人已經解決了這個,把它用在工作的jquery以下MediaElement.js阻止其他玩家開始遊戲

$('video,audio').each(function() { 
    $(this)[0].pause(); 
}); 

你能幫我,我有點小白在這裏,但究竟在那裏我把這些代碼?或者,我應該把它放在jquery.js文件中。我不能得到它的工作

我需要我的其他球員停止播放,如果另一個開始。任何幫助將不勝感激,謝謝

回答

1

/*new MediaElementPlayer('.player_1', {success: function(media, node, player) { 
 
    // this will be undefined since it's the player with buttons 
 
alert(player.paused); 
 
    // this will be a real value since it's the underlying mediaelement 
 
alert(media.paused); 
 
} 
 
});*/ 
 
$(document).ready(function() { 
 
    $('audio').mediaelementplayer({ 
 
     alwaysShowControls: true, 
 
     features: ['playpause','volume','progress'], 
 
     audioVolume: 'horizontal' 
 
     //audioWidth: 400, 
 
     //audioHeight: 120 
 
    }); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="http://mediaelementjs.com/js/mejs-2.8.2/mediaelement-and-player.min.js"></script> 
 
<link href="http://mediaelementjs.com/js/mejs-2.8.2/mediaelementplayer.min.css" rel="stylesheet"/> 
 
<audio src="http://mediaelementjs.com/media/AirReview-Landmarks-02-ChasingCorporate.mp3" class="player_1"></audio> 
 
<audio src="http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3" class="player_2"></audio>

+0

那是偉大的!非常感謝你。 – CaptainWeirdBeard 2014-09-25 17:47:07