If I use mp3: "/Music/StreamUploadedSongs/1"
in the following code:
var player = new $("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: "/Music/StreamUploadedSongs/1",
});
},
cssSelectorAncestor: "#jp_container_1",
swfPath: "~Scripts/Jplayer/jquery.jplayer.swf",
useStateClassSkin: true,
autoBlur: false,
keyEnabled: true
}
});
Here is what it looks like, you can see jplayer isn't moving the times correctly (they are overlapping) and also the seek/play bar doesn't work although the song can still be played:
Html Markup:
<audio id="jp_audio_0" preload="metadata" src="http://localhost:6060/Music/StreamUploadedSongs/1"></audio>
Music Controller:
public ActionResult StreamUploadedSongs(int id)
{
byte[] song = db.UploadedSongs.Where(x => x.Id == id).FirstOrDefault().SongBytes;
return File(song, "audio/*");
}
If i change the mp3 property to this instead: mp3: "http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3"
then it works perfectly.
var player = new $("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: "http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3",
});
},
cssSelectorAncestor: "#jp_container_1",
swfPath: "~Scripts/Jplayer/jquery.jplayer.swf",
useStateClassSkin: true,
autoBlur: false,
keyEnabled: true
}
});
Here is what it looks like, working properly, the seek/play bar works and jplayer has moved the time to the correct positions:
Html Markup: <audio id="jp_audio_0" preload="metadata" src="http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3"></audio>
I have other jPlayers on other pages and its the exact same with them too.
Edit: Just tried this:
public string StreamUploadedSongs(int id)
{
string filePath = Server.MapPath(Url.Content("~/Content/TSP-01-Cro_magnon_man.mp3"));
return filePath;
}
I put the mp3 file in that directory but it doesn't play at all now. If I paste this into url http://localhost:6060/Music/StreamUploadedSongs/1034"
it just returns I:\Users\UserName\Desktop\MusicSite\MusicSite\MusicSite\Content\TSP-01-Cro_magnon_man.mp3 instead of playing the song.