0
我在收到我上傳的特定mp3時遇到了一些麻煩。使用回形針創建mp3上傳
我有一個Ruby on Rails應用程序,我使用回形針上傳實際的mp3。我正在使用Javascript庫(稱爲jp-player)。我知道mp3文件已經上傳,但我沒有正式播放它。如果我點擊play
按鈕,則什麼都不會發生。
我的模型看起來是這樣的:
has_attached_file :mp3
validates_attachment :mp3, :content_type => { :content_type => ["audio/mpeg", "audio/mp3"] }, :file_name => { :matches => [/mp3\Z/] }
我的控制器看起來像
def create
@cafe = current_user.cafes.build(cafe_params)
if @cafe.save
redirect_to @cafe
else
render 'new'
end
end
def cafe_params
params.require(:cafe).permit(:name, :description, :street_address, :state, :editors_note, :website, :image, :mp3)
end
我的觀點(我有這樣的一個部分,我在不同的看法我打電話)
#cafe_content
#jquery_jplayer_1.jp-jplayer
#jp_container_1.jp-audio
.jp-type-single
.jp-gui.jp-interface
%ul.jp-controls
%li
%a.jp-play{:href => "javascript:;", :tabindex => "1"}
%li
%a.jp-pause{:href => "javascript:;", :tabindex => "1"}
%li
%a.jp-mute{:href => "javascript:;", :tabindex => "1", :title => "mute"}
%li
%a.jp-unmute{:href => "javascript:;", :tabindex => "1", :title => "unmute"}
.jp-progress
.jp-seek-bar
.jp-play-bar
.jp-time-holder
.jp-current-time
.jp-volume-bar
.jp-volume-bar-value
.jp-no-solution
%span Update Required
To play the media you will need to either update your browser to a recent version or update your
= succeed "." do
%a{:href => "http://get.adobe.com/flashplayer/", :target => "_blank"} Flash plugin
:javascript
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function() {
$(this).jPlayer("setMedia", {
mp3: "<%= @cafe.mp3.url %>",
});
},
swfPath: "/js",
supplied: "mp3"
});
});
有誰知道是否有什麼我失蹤,可以得到這個正常運行?