2016-02-23 99 views
0

沒有錯誤我使用在我的網站jPlayer但它不工作並且在控制檯調試以及 所有文件沒有錯誤都包含在正確的順序 jPlayer沒有工作,在控制檯

<script data-main="/scripts/main" src="{{ URL::asset('scripts/require.js') }}"></script> 

<script type="text/javascript" src="{{URL::asset('scripts/jquery.js')}}"></script> 

指數

<li> 
    <div class="userPhoto"> <img src="images/artists/1.png"> </div> 
    <div class="userSummary" > 
    <a href="/data/2.mp3" class="track" title="Ghoom Tana 1">d</a> 
    <strong> 
     <a href="#"> 
     John Doe 
     </a> 
    </strong> 
    <span> 
    <a href="#">Jazz</a>/<a href="#">Big Band</a>, 
    <a href="#">Swing</a> 
    </span> 
    </div> 
    <div class="featuredPlayer"> 
    <span class="track-name"> </span><br> 
    <div class="playerControls"> 
     <span class="jp-current-time"></span> 
     <span class="jp-stop" title="Stop">Stop</span> 
     <span class="jp-play" title="Play">Play</span> 
     <span class="jp-pause" title="Pause">Pause</span> 
     <span class="jp-duration"></span> 
    </div> 
    <div class="thePlayer"><a href="#" class="likeIt" title="Like?">w</a></div> 
    </div> 
</li> 

JS

$('.userPhoto img').each(function() { 
    $this = $(this); 
    var $height = $this.height(); 
    console.log($height); 
    $this.parent().parent().find(".featuredPlayer").css("height", $height); 
}); 


$('.userSummary > a').click(function() { 

    $(this).parents().find('.featuredPlayer').addClass('show'); 
    $(this).parents().siblings().find('.featuredPlayer').removeClass('show'); 

}); 


$('.jp-stop').click(function() { 
    $(this).parents().find('.featuredPlayer').removeClass('show'); 
}); 

var container = $('nav#left').jScrollPane({ 
    showArrows: false, 
    autoReinitialise: false 
}); 
var jsp = container.data('jsp'); 

$(window).on('resize', function() { 
    jsp.reinitialise(); 
}); 

// Local copy of jQuery selectors, for performance. 
var my_jPlayer = $("#jquery_jplayer"), 
     my_trackName = $("#jp_container .track-name"), 
     my_playState = $("#jp_container .play-state"), 
     my_extraPlayInfo = $("#jp_container .extra-play-info"); 

// Some options 
var opt_play_first = false, // If true, will attempt to auto-play the default track on page loads. No effect on mobile devices, like iOS. 
     opt_auto_play = true, // If true, when a track is selected, it will auto-play. 
     opt_text_playing = "Now playing", // Text when playing 
     opt_text_selected = "Track selected"; // Text when not playing 

// A flag to capture the first track 
var first_track = true; 

// Change the time format 
$.jPlayer.timeFormat.padMin = true; 
$.jPlayer.timeFormat.padSec = true; 
// $.jPlayer.timeFormat.sepMin = " min "; 
// $.jPlayer.timeFormat.sepSec = " sec"; 

// Initialize the play state text 
my_playState.text(opt_text_selected); 

// Instance jPlayer 
my_jPlayer.jPlayer({ 
    ready: function() { 
     $("#jp_container .track-default").click(); 
    }, 
    timeupdate: function (event) { 
     my_extraPlayInfo.text(parseInt(event.jPlayer.status.currentPercentAbsolute, 10) + "%"); 
    }, 
    play: function (event) { 
     my_playState.text(opt_text_playing); 
    }, 
    pause: function (event) { 
     my_playState.text(opt_text_selected); 
    }, 
    ended: function (event) { 
     my_playState.text(opt_text_selected); 
    }, 
    //swfPath: "../../dist/jplayer", 
    cssSelectorAncestor: "#jp_container", 
    supplied: "mp3", 
    wmode: "window", 
    smoothPlayBar: true 
}); 

// Create click handlers for the different tracks 
$("#jp_container .track").click(function (e) { 
    my_trackName.text($(this).attr('title')); 
    my_jPlayer.jPlayer("setMedia", { 
     mp3: $(this).attr("href") 
    }); 

    my_jPlayer.jPlayer("play"); 

    first_track = false; 
    $(this).blur(); 
    return false; 
}); 

$('.profilePlaylist ul li ul li a.track').click(function (e) { 

    $('.profilePlaylist ul li ul').removeClass('playing'); 

    var playing = $(this).parent().parent().parent().find('ul'); 

    var notplaying = $(this).parent().parent().parent().find('ul.playing'); 

    playing.toggleClass('playing'); 

    notplaying.toggleClass('playing'); 

    e.preventDefault(); 
}); 


}); 

回答

0

我沒有足夠的評論聲望。

您的jPlayer正在使用$("#jquery_jplayer"),但是您的html中沒有任何內容指定它。你有沒有離開這個或我錯過了什麼?

$("#jp_container .track-default").click();同樣如此您的html中沒有track-default元素。你在哪裏指定jPlayer的默認音軌?

也許這可以幫助:http://jsfiddle.net/XLNCY/19717/

如果我失去了一些東西,請告訴我。或者,如果你可以發佈完整的HTML與你在jQuery中使用的類,那會更好。如果可以的話,Jsfiddle會很棒。

相關問題