Thanks for any help in advance.
So, I'm storing songs in a filesystem with Paperclip. I'm then trying to play these songs with jPlayer.
I have followed all the directions but can't seem to get the audio playing via clicking on a link_to method that is supposed to parse the audio to jPlayer.
Basically a song should play when the button 'Play Song' is clicked.
My jPlayer function looks like this:
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: '<source>'
});
},
swfPath: "jplayerflash",
supplied: "mp3",
});
});
My view looks like this:
<td><%= link_to 'Play Song', song_upload.song.url, :class => "html5" %></td>
The audio files are stored via paperclip in assets/user_song_uploads... The songs are all MP3 format and I'm using Chrome so everything should work.
The problem comes in when trying to set the media in jPlayer.
Link to how jPlayer should be implemented This where I initially learned how to implement a music listening application. Half way through in the section 'Streaming with HTML5 Audio' is why i used '' - but clearly not working with this implementation.
Sorry for the late response but I figured out my answer.
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
swfPath: "/app/assets/jplayerflash",
supplied: "mp3",
wmode: "window"
});
$('a.play').click(function(e) {
e.preventDefault();
$("#jquery_jplayer_1")
.jPlayer("setMedia", {mp3: this.href })
.jPlayer("play");
and my view:
<td><%= link_to 'Play Song', song_upload.song.url, :class => "play" %></td>