我正在使用 getshopped.org 的 jquery-jplayer 插件。我在他们的论坛上问过这个问题,但遗憾的是似乎不可能在那里得到任何帮助。所以我的问题是我想通过“pauseOthers”方法在启动时暂停所有 jplayer 实例。虽然不起作用...任何帮助将不胜感激!这是我的代码:
<script type='text/javascript'>
jQuery(document).ready(function($){
// Local copy of jQuery selectors, for performance.
//array of players and int variables for uniquely identifying each player
var jPlayer_array = $(".jquery_jplayer");
var playerID;
var fileID;
var jpPlayTime = new Array();
var jpTotalTime= new Array();
var song = new Array();
<?php
if(isset($_SESSION['jplayer_plugin_ids'])){
foreach((array)$_SESSION['jplayer_plugin_ids'] as $fileid){
$file_data = get_post($fileid);
$mp3_path= WPSC_PREVIEW_URL."".addslashes($file_data->post_title)."";
if(!empty($file_data)){?>
jpPlayTime_<?php echo $fileid; ?> = $("#jplayer_play_time_<?php echo $fileid; ?>");
jpTotalTime_<?php echo $fileid; ?> = $("#jplayer_total_time_<?php echo $fileid; ?>");
//Console: Uncaught TypeError: Cannot read property 'play' of undefined
$('#jquery_jplayer_<?php echo $fileid; ?>').bind($.jPlayer.event.play, function() {
$(this).jPlayer("pauseOthers");});
$('#jquery_jplayer_<?php echo $fileid; ?>').jPlayer({
ready: function () {
this.setFile('<?php echo $mp3_path; ?>');
},
swfPath: '<?php echo WP_CONTENT_URL."/plugins/jPlayerPlugin/js"; ?>',
volume: 50,
customCssIds: true
})
.jPlayer( "cssId", "play", "jplayer_play_<?php echo $fileid; ?>" )
.jPlayer( "cssId", "pause", "jplayer_pause_<?php echo $fileid; ?>" )
.jPlayer( "cssId", "loadBar", "jplayer_load_bar_<?php echo $fileid; ?>")
.jPlayer( "cssId", "playBar", "jplayer_play_bar_<?php echo $fileid; ?>")
.jPlayer( "cssId", "volumeMin", "jplayer_volume_min_<?php echo $fileid; ?>")
.jPlayer( "cssId", "volumeMax", "jplayer_volume_max_<?php echo $fileid; ?>")
.jPlayer( "cssId", "volumeBar", "jplayer_volume_bar_<?php echo $fileid; ?>")
.jPlayer( "cssId", "volumeBarValue", "jplayer_volume_bar_value_<?php echo $fileid; ?>")
.jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
jpPlayTime_<?php echo $fileid; ?>.text($.jPlayer.convertTime(playedTime));
jpTotalTime_<?php echo $fileid; ?>.text($.jPlayer.convertTime(totalTime));
})
.jPlayer("onSoundComplete", function() {
//COMMENT THIS LINE OUT IF YOU WANT THE TRACK TO LOOP
//this.element.jPlayer("play");
});
<?php
}
}
}
?>
});
</script>