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
- gem 'flowplayer' in your gem file
- rails g flowplayer or rails g flowplayer commercial
- add javascript_include_tag 'flowplayer.min.js' to your application layout
- 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();'
精彩评论