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>