【问题标题】:Rails 3 Flowplayer Gem UsageRails 3 Flowplayer 宝石使用
【发布时间】:2011-03-11 00:26:42
【问题描述】:

我正在尝试在我的 Rails 3 应用程序中使用 flowplayer gem。我已按照安装说明进行操作

Rails 3 的 Flowplayer 助手 应用

  1. gem 文件中的“flowplayer”
  2. rails g flowplayer 或 rails g flowplayer 商业版
  3. 将 javascript_include_tag 'flowplayer.min.js' 添加到您的 应用布局
  4. 阅读下文

用法

对于 JQuery

= flowplayer_for :video, '/flowplayer.swf', 'jquery' 做 |播放器| - player.playlist [{:url => "video_still.jpg" }, {:url => "video_512x288.flv", :autoPlay => 假,:自动缓冲 => 真 }] - player.onLoad 做 - 'this.unmute();'

对于原型

= flowplayer_for :video, '/flowplayer.swf', 'prototype' 做 |播放器| - player.playlist [{:url => "video_still.jpg" }, {:url => "video_512x288.flv", :autoPlay => 假,:自动缓冲 => 真 }] - player.onLoad 做 - 'this.unmute();'

这里的配置是一样的

http://flowplayer.org/documentation/api/index.html 待办事项

更多文档

在第 1 步之后我执行了

bundle install

成功了。

对于第 2 步,我执行了第一个选项

rails g flowplayer

成功了。

对于第 3 步,我添加了

= javascript_include_tag 'flowplayer.min.js'

到我的 application.html.haml 文件的头部;成功了。

对于第 4 步,我添加了

%a#video{:style => "display:block;width:512px;height312px;"}

到我的 home.html.haml 文件;这是成功的,相当于

<a id='video' style='display:block;width:512px;height312px;'>

根据this HTML2HAML converter

现在我来到了最后一部分。我正在使用 jQuery,但我不知道将最后一段 sn-p 代码放在哪里。

任何帮助将非常感谢!

【问题讨论】:

    标签: ruby-on-rails-3 gem haml flowplayer


    【解决方案1】:

    我知道这是旧的,但对其他人来说 - 您可以将最后一段代码放在其余代码之后。警告:最新的 flowplayer gem 中有一个错误。 flowplayer_for 只需要两个参数(导致它总是使用 jQuery),而示例显示了三个参数。我已经向作者发送了一个拉取请求来更改它。

    所以(在哈姆里):

    - content_for :head do
      = javascript_include_tag "flowplayer.min.js"
    
    %a#video{:style => "display:block;width:512px;height312px;"}
    
    = flowplayer_for :video, '/flowplayer.swf'do |player|
      - player.playlist [{:url => "video_still.jpg" }, {:url => "video_512x288.flv", :autoPlay => false, :autoBuffering => true }] 
      - player.onLoad do 
        - 'this.unmute();' 
    

    【讨论】:

    • 您好,我已按照所有步骤操作,但在呈现页面时出现以下错误:undefined method flowplayer_for' for #:0x007fea92419220>` 对此有何建议?谢谢!
    • 这么久了,真的不记得了。但是,如果它不知道flowplayer_for,要么该方法不再存在于 gem 中,要么您还没有包含/安装 gem。很抱歉没有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-31
    • 2012-08-22
    • 1970-01-01
    相关资源
    最近更新 更多