I am using jPlayer on my website but it is not working and there is no error in console to debug as well All files are included in correct order Header
<script data-main="/scripts/main" src="{{ URL::asset('scripts/require.js') }}"></script>
<script type="text/javascript" src="{{URL::asset('scripts/jquery.js')}}"></script>
Index
<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();
});
});
I don't have enough reputation for a comment.
Your jPlayer is using $("#jquery_jplayer")
, but there is nothing in your html specifying this. Have you left this out or am I missing something?
The same goes for $("#jp_container .track-default").click();
You don't have track-default element in your html. Where are you specifying the default tracks for your jPlayer?
Maybe this can help: http://jsfiddle.net/XLNCY/19717/
If I am missing something please tell me. Or if you can post full HTML with classes you are using in jquery that would be better. A Jsfiddle would be great if you could.