I am trying to change the song on jQuery, using the developers guide, i have come up with this function:
<script type="text/javascript">
$(document).ready(function(){
$('.embedinfo').click(function() {
$("#jquery_jplayer_1").jPlayer( "clearMedia" );
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3:"/audio/<?php echo $audioarray[0]['audio']; ?>"
}).jPlayer("<?php if(empty($auto)){ echo "pause"; } elseif($auto==1){ echo "play"; } ?>");
},
swfPath: "/js/Jplayer.swf",
supplied: "mp3",
wmode: "window",
solution:"flash,html",
volume:"1"
});
});
});
The setMedia
function is actually identical to the function i use to set the music initially (which does work), however this function to change the music from a click is not working.
The clearMedia
function is working, just the set isnt. Why is it not working?
I found a solution
instead of using
$("#jquery_jplayer_1").jPlayer( "clearMedia" );
which removes the media, use
$("#jquery_jplayer_1").jPlayer( "destroy" );
which unbinds all instances of .jPlayer, allowing the media to be updated from scratch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With