Simple Rails helper for rendering JWPlayer 5.4 using SWFObject v2.2
Is opensource player supporting video (for example .mp4, .mov, .f4v, .flv), audio (.mp3) and image (.jpg, .png, .gif) files (full list).
- add
gem 'jw_player_helper'
into yourGemfile
- add
<%= javascript_include_tag 'swfobject' %>
in your layout - now you can use
<%= video_player(flashvars={}, attributes={}, params={}) %>
to render JW Player
- add
config.gem "jw_player_helper"
into yourconfig/environment.rb
- add
<%= javascript_include_tag 'swfobject' %>
in your layout - now you can use
<%= video_player(flashvars={}, attributes={}, params={}) %>
to render JW Player
:file => "relative path to file (for example: /video/pf2011.flv)",
:image => "relative path to splash image (for example: /video/pf2011.jpg)",
:bufferlength => 1,
:autostart => false
Full list of JW Player flashvars
:id => 'jw_player',
:name => 'jw_player',
:width => 300,
:height => 300,
:message => "Get the Adobe Flash Player to see this video.",
:element => "div",
:onmouseover => nil, # you can define javascript callbacks for element
:onmouseout => nil,
:onclick => nil
:allowfullscreen => true,
:allowscriptaccess => 'always'
<%= video_player({:file => "/video/pf2011.flv", :image => "/video/pf2011.jpg"}) %>
renders JW Player with splash screen pf2011.jpg
<%= video_player({:file => "/video/pf2011.flv", :image => "/video/pf2011.jpg"}, {:width => 640, :height => 480, :id => "pf2011_video"}) %>
renders JW Player with resolution 640x480px
and id pf2011_video
<%= video_player({:file => "/video/pf2011.flv", :image => "/video/pf2011.jpg", :mute => true}, {:width => 640, :height => 480, :id => "pf2011_video", :onclick => "alert('clicked!');"}) %>
renders muted JW player with javascript alert when user click on video
Gem is packed with few skins
-
Usage: add :skin => 'name' to your flashvars. For example: <%= video_player({:file => "/video/pf2011.flv", :image => "/video/pf2011.jpg", :skin => "glow"}) %>
You can find more skins here.
Usage: Copy downloaded zip into RAILS_ROOT/public/swf/skins
and set :skin => 'name without .zip extension'
flashvar