I have a jplayer component in my website. I want to change the variable of mp3 which is sky.mp3 dynamically, that is through an ajax function. How can I do it with jquery?
var myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
{
mp3:"sky.mp3"
}, {
cssSelectorAncestor: "#cp_container_1",
swfPath: "js",
supplied: "mp3",
wmode: "window",
keyEnabled: true
});
<div id="cp_container_1">
<a class="cp-play" onClick="return false;" href="#"></a>
</div>
It's all in the docs for jPlayer: http://www.jplayer.org/latest/developer-guide/#jPlayer-setMedia
Use the jPlayer.setMedia method to do so. Assuming you're using the jQuery jPlayer plugin:
$('#jquery_jplayer_1').jPlayer('setMedia',{
mp3: '/path/to/another-sky.mp3'
});
Assuming you're playing around from jPlayer's demo (http://www.jplayer.org/latest/demo-05/), there are other methods available from jPlayer's API:
$('#jquery_jplayer_1').jPlayer('pause');
$('#jquery_jplayer_1').jPlayer('play');
$('#jquery_jplayer_1').jPlayer('volume',10);
Etc... just make sure jPlayer emits its ready event before you attempt to interface with it.