Add to your Gemfile
gem 'videojs_rails'
And run bundle to install the library.
bundle
Add the resources to your application.js file
# app/assets/javascripts/application.js
//= require video
And that resource to application.css file
/*
*= require_self
*= require video-js
*/
currently skins are not implemented (after migrate to 4.1 version)
And to production.rb add this line
config.assets.precompile += %w( video-js.swf vjs.eot vjs.svg vjs.ttf vjs.woff )
<%= videojs_rails sources: { mp4: "http://domain.com/path/to/video.mp4", webm: "http://another.com/path/to/video.webm" }, width:"400" %>
This is currently experimental function.
<%= videojs_rails sources: { mp4: "http://domain.com/path/to/video.mp4" }, width:"400", captions: { en: "http://domain.com/path/to/captions.vvt" } %>
http://videojs.com/ http://videojs.com/#getting-started
- Checkout release tag e.g.
git checkout v4.6.1
. - Run the build i.e.
grunt
.
$ cp $VIDEO_JS_HOME/dist/video-js/video-js.swf $VIDEO_JS_RAILS_HOME/vendor/assets/flash/
$ cp $VIDEO_JS_HOME/dist/video-js/font/* $VIDEO_JS_RAILS_HOME/vendor/assets/fonts/
$ cp $VIDEO_JS_HOME/dist/video-js/video.dev.js $VIDEO_JS_RAILS_HOME/vendor/assets/javascripts/video.js.erb
$ cp $VIDEO_JS_HOME/dist/video-js/video-js.css $VIDEO_JS_RAILS_HOME/vendor/assets/stylesheets/video-js.css.erb
The following files need to be modified to use the Rails asset_path
helper e.g. for the location of the Flash player SWF file and for the location of the various font files:
- $VIDEO_JS_RAILS_HOME/vendor/assets/javascripts/video.js.erb
- $VIDEO_JS_RAILS_HOME/vendor/assets/stylesheets/video-js.css.erb