pesolari
pesolari

Reputation: 105

Mp3-player in Rails 3 app

I want to put a player on a web page and I am using mp3_player (https://github.com/sekrett/mp3_player). I have the plugin installed and everything works, except that the player can't find the path to the file. I have put the file named file.mp3 in the public folder and made the following tags in my code:

$ <%= mp3_player("/public/file.mp3") %>

The player appears on the page, but when I click play the player says the file is missing. The following routingerror appears in the log:

ActionController::RoutingError (No route matches [GET] "/public/file.mp3")

What am I doing wrong and is there an easy way to fix this?

Upvotes: 1

Views: 1956

Answers (2)

jefflunt
jefflunt

Reputation: 33954

kasper375's suggestion should work. If you're not concerned about pre-HTML5 support, you can also just wrap the audio file in an audio tag, and the browser will provide an in-browser player for you automatically. .mp3 and .ogg files are typically supported, as I understand.

As a side note, video playback is just as easy with HTML5, with the video tag.

Upvotes: 1

kasper375
kasper375

Reputation: 171

Try to write <%= mp3_player("/file.mp3") %>. "Public" folder is a root folder of your project.

Upvotes: 1

Related Questions