I'm trying to use jPlayer to play an mp3. I have the jPlayer CSS and images working, now it's just a matter of playing the mp3. To do so, I include the following javascript in the application.html.erb layout's head:
<script type="text/javascript">
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: "media/sound.mp3",
// m4a: "http://www.jplayer.org/audio/m4a/Miaow-07-Bubble.m4a",
// oga: "http://www.jplayer.org/audio/ogg/Miaow-07-Bubble.ogg"
});
},
swfPath: "/javascripts",
supplied: "mp3, m4a, oga"
});
});
When I load the page and click the play button, I get the following routing error:
ActionController::RoutingError (No route matches [GET] "/calls/media/sound.mp3")
Would someone mind taking a spare minute to explain to me why this is? Should I be including the javascript in something like this?
<%= javascript_tag 'some js code' %>
Any assistance is very much appreciated. Thanks in advance.
I realized I was I was missing a starting / i.e. changed "media/sound.mp3" to "/media/sound.mp3".
Then, I decided to use a path helper