jplayer - 未捕获的TypeError:无法读取未定义的属性“play”

时间:2012-05-29 12:43:41

标签: jquery jplayer

我正在使用来自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
        }
    }
}

&GT;

});
</script>

0 个答案:

没有答案