<script type="text/javascript">
var url = "http://localhost:8000/api/songs/rock";
var song;
var artist;
var genre;
var album;
$.ajax({
url: url,
type: 'GET',
dataType: 'json', // added data type
success: function(res) {
console.log(res);
song = res.song;
artist = res.artist.name;
album = res.album.albumb_title;
genre = res.genre.name;
console.log(song);
console.log(artist);
console.log(genre);
console.log(album);
}
});
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: song,
});
},
swfPath: "http://jplayer.org/latest/js",
supplied: "mp3",
});
});
So I am using ajax to call my local API and trying to send my response to the jplayer function. I am not able to figure out the way around to give "mp3" a url and play a song from that.