I need to be able to set up links that will send a song to a central JPlayer.
For example, on a store and someone wants to sample a track before purchasing it, you click on the link and it sends the information to JPlayer and starts playing said track.
I have seen examples of using some similar to below in other stackoverflow questions here (7 years old) however cannot get it to work.
Update: I have tried the below but the link doesn't do anything.
$(document).ready(function(){
$("#jquery_jplayer").jPlayer({
swfPath: "../../dist/jplayer",
supplied: "mp3",
wmode: "window"
});
$('a[data-mp3]').click(function(e) {
e.preventDefault();
// replace #my-j-player by the id of your instance
$("#jquery_jplayer").jPlayer("setMedia", {
mp3: $(this).attr("data-mp3"),
oga: $(this).attr("data-ogg")
}).jPlayer("play");
});
});
<a href="#" data-mp3="http://www.jplayer.org/audio/mp3/Miaow-01-Tempered-song.mp3">TEST</a>