开发者

Rails 3 Flowplayer Gem Usage

I'm attempting to use the flowplayer gem in my Rails 3 app. I've followed the installation instructions

Flowplayer Helper for Rails 3 applications

  1. gem 'flowplayer' in your gem file
  2. rails g flowplayer or rails g flowplayer commercial
  3. add javascript_include_tag 'flowplayer.min.js' to your application layout
  4. read below

Usage

For JQuery

= 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();'

For Prototype

= flowplayer_for :video, '/flowplayer.swf', 'prototype' do |player| - player.playlist [{:url => "video_still.jpg" }, {:url => "video_512x288.flv", :autoPlay => false, :autoBuffering => true }] - player.onLoad do - 'this.unmute();'

Configs are the same ones here

http://flowplayer.org/documentation/api/index.html TODO

More documentation

After Step 1 I executed

bundle install

Which was successful.

For Step 2, I executed the first option

rails g flowplayer

Which was successful.

For Step 3, I added

= javascript_include_tag 'flowplayer.min.js'

to the head of my application.html.haml file; which was successful.

For Step 4, I added

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

to my home.html.haml file; which was successful and the equivalent of

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

as per this HTML2HAML converter.

Now I've come to the last portion. I am using jQuery, but I have no idea where to put this last snippet of code.

Any help would be开发者_运维百科 great thanks!


I know this is old but for anyone else - you can put the last bit of code right after the rest of your code. Caveat: There is a bug in the latest flowplayer gem. flowplayer_for only takes two parameters (causing it to always use jQuery) while the example shows three parameters. I've sent the author a pull request to change it.

So (in haml):

- 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();' 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜