I'm trying to use a jPlayer to trigger the player in my template. I need to pass a value to the mp3 option but I don't know how to set mp3 in setMedia
to music
.
$(document).ready(function(){
var music = $(".album-playlist li").first().find("input").val();
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: music,
}).jPlayer("");
},
swfPath: "http://mysite.com/wp-content/themes/beta/libs",
supplied: "mp3"
});
});
Edit: Your question was about how to print a variable, but it seems that you actually want to figure out how to setMedia
of a jPlayer
Check out this link http://www.jplayer.org/latest/developer-guide/#jPlayer-setMedia
$("#jquery_jplayer_1").jPlayer( {
ready: function() {
$(this).jPlayer( "setMedia", {
mp3: "yourpath/movie.mp3"
});
},
supplied: "mp3"
);
In your case all you have to do is move $music
to the right scope. Like so:
$(document).ready(function(){
var music = $(".album-playlist li").first().find("input").val();
$("#jquery_jplayer_1").jPlayer( {
ready: function() {
$(this).jPlayer( "setMedia", {
mp3: music
});
},
supplied: "mp3"
);
$("#jquery_jplayer_1").append("Mp3: " + music);
});