我遇到了使用播放flv文件的flowplayer的Rails应用程序。 我正在使用flowplayer gem here。我按照说明和使用部分,你必须在jQuery或Prototype之间选择一些代码。我不知道如何把这段代码,因为我不知道它的语言。它是Ruby代码吗? jQuery代码? 无论如何,有没有人试过并成功播放Flash视频呢?如果有人能告诉我如何处理那些困扰我的代码,我会很感激。
提前致谢。
更新
我使用视图中的代码更新问题以缩小问题范围。
<a href="<%= url_for(:controller => "attachments", :action => "public_download", :id => @attachment)%>"
id='video' style='display:block;width:512px;height:312px;'>
<%= flowplayer_for :video, 'flowplayer.swf' do |player|%>
<%- player.playlist [{:url => "video_still.jpg" }, {:url => "#{Rails.root}/public#{@attachment.arxiu.url}", :autoPlay => false, :autoBuffering => true }] %>
<%- player.onLoad do %>
<%- 'this.unmute();' %>
<% end %>
<% end %>
</a>
第一行是动作的网址。这意味着,如果我点击视频我下载它。 此操作有效,未显示的是播放视频的播放器。所以我可以将它缩小到来自github的代码。
答案 0 :(得分:0)
这是红宝石代码。虽然我还没有使用过这个代码,但是这个代码应该出现在你想要的flowplayer javascript标签出现的地方:
# params: container_element_id, player_path, library
flowplayer_for :video, '/flowplayer.swf', 'jquery' do |player|
player.playlist [{:url => "video_still.jpg" }, {:url => "video_512x288.flv", :autoPlay => false, :autoBuffering => true }]
player.onLoad do
'this.unmute();'
end
end
该方法的来源是here。
我的2c虽然你应该使用不使用插件或gem,但流媒体很容易直接在你的布局和视图上实现,这样你就可以消除不必要的依赖。
答案 1 :(得分:0)
我选择删除gem并通过脚本执行。现在它完美无缺。看来gem没有找到插件或文件,如果你发现一点javascript我建议你通过脚本来做,你会省下很多痛苦。