[jPlayer] How to turn off Auto-Start?

544 views
Skip to first unread message

bezz

unread,
May 16, 2010, 11:47:07 AM5/16/10
to jPlayer: the CSS styleable jQuery audio player plugin
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.jplayer.min.js"></
script>
<script type="text/javascript">
<!--
$(document).ready(function(){

var jpPlayInfo = $("#play-info");

$("#jquery_jplayer").jPlayer({
ready: function () {
$("#track-01").trigger("click");
},
customCssIds: true
})
.jPlayer("cssId", "play", "play")
.jPlayer("cssId", "pause", "pause")
.jPlayer("cssId", "stop", "stop")
.jPlayer("cssId", "volumeMin", "vmin")
.jPlayer("cssId", "volumeMax", "vmax")
.jPlayer("cssId", "volumeBar", "vbar")
.jPlayer("onProgressChange", function(lp,ppr,ppa,pt,tt) {
jpPlayInfo.text("at " + parseInt(ppa)+"% of " +
$.jPlayer.convertTime(tt) + ", which is " +
$.jPlayer.convertTime(pt));
});

$("#track-01").click( changeTrack );
$("#track-02").click( changeTrack );
$("#track-03").click( changeTrack );
$("#track-04").click( changeTrack );
$("#track-05").click( changeTrack );
$("#track-06").click( changeTrack );
$("#track-07").click( changeTrack );
$("#track-08").click( changeTrack );
$("#track-09").click( changeTrack );
$("#track-10").click( changeTrack );
$("#track-11").click( changeTrack );
$("#track-12").click( changeTrack );
$("#track-13").click( changeTrack );
$("#track-14").click( changeTrack );
$("#track-15").click( changeTrack );
$("#track-16").click( changeTrack );

function changeTrack(e) {
$("#trackname").text($(this).text());
$("#jquery_jplayer").jPlayer("setFile", $
(this).attr("href")).jPlayer("play");
$(this).blur();
return false;
}

$.jPlayer.timeFormat.padMin = false;
$.jPlayer.timeFormat.padSec = false;
$.jPlayer.timeFormat.sepMin = "min ";
$.jPlayer.timeFormat.sepSec = "sec";
});
-->
</script>

--
You received this message because you are subscribed to the Google Groups "jPlayer: the CSS styleable jQuery audio player plugin" group.
To post to this group, send email to jpl...@googlegroups.com.
To unsubscribe from this group, send email to jplayer+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jplayer?hl=en.

Jonathan2

unread,
May 16, 2010, 12:45:44 PM5/16/10
to jPlayer: the CSS styleable jQuery audio player plugin
Thanks for that random lump of code without explanation.

However,here's your answer:

http://lmgtfy.com/?q=jplayer+turn+off+autostart

Mark P

unread,
May 16, 2010, 7:57:40 PM5/16/10
to jPlayer: the CSS styleable jQuery audio player plugin
Hello Bezz,

It looks like you are using demo 4 as a starting point. As Jonathan
wrote, it would help to give an explanation rather than purely rely on
the title. Your other post got flagged as spam because the system
thought you were a spammer.

On to your problem...

This line here is making jPlayer auto play the track. In the jPlayer
ready function:

ready: function () {
$("#track-01").trigger("click");
}

If you comment it out, the track will not play on page load. However,
the 'play' button will not work until the user clicks on one of the
tracks.

To solve that problem, I'd suggest something like:

ready: function () {
$("#trackname").text($("#track-01").text());
$("#jquery_jplayer").jPlayer("setFile",$
("#track-01").attr("href"));
}

That should do it.

Best regards,
Mark P.

@Jonathan: That did make me laugh. But in fairness this demo is a
little more complicated to disable the auto-play and I'm not sure if
there is a solution for disabling it given in the group.

Hmmm... On that point, I'll add a few terms below to help others find
this information in the group.

Search tags: demo-04, demo 4, autoplay, autostart, disable.
Reply all
Reply to author
Forward
0 new messages