Try Free

The Bitmovin HTML5 Player on Ruby on Rails in two easy steps

ruby-logo
Most Ruby developers will agree that Rubygems is by far the easiest way to get new components into a project. So we decided to make it super easy for Rails developers to get started with the Bitmovin Player by providing an easy to use Rails plugin that will get you up and running within 5 minutes or less. Besides that the gem will also take care of your API-Key and provide you with a Rails helper for embedding the player!

Setup the Bitmovin Rails Player

After installation, the following code is all you need to write yourself to embed the Bitmovin Player into your Rails view:

 <%= bitmovin_player( 
width: "800px", 
height: "450px", 
dash: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/mpds/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd" 
hls: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8" 
poster: "//bitmovin-a.akamaihd.net/content/MI201109210084_1/poster.jpg") %>

Setup is super simple – just two commands are necessary, the rest is either automated or explained during the setup process. Once the install is done you get a Rails helper that automatically generates the Bitmovin Player Javascript alongside with the given configuration. It supports all configuration options that the player would accept in Javascript but without having to write any Javascript in your views. The configuration options are just passed as a standard Ruby hash to reduce the amount of Spaghetti Code otherwise necessary.

So lets get started by installing the Bitmovin-Player-Rails Gem to your application’s Gemfile:

$ echo "gem 'bitmovin-player-rails'" >> Gemfile
$ bundle install

Afterwards just run bundle install and the Gem will be downloaded from Rubygems.org and installed to your application.

It comes with it’s own setup generator that will ask you for your Bitmovin API key and which version of the Player you want to run. It then saves these settings in your Rails application configuration. Just run:

$ rails generate bitmovin_player

After completing the setup you end up with a Rails helper called bitmovin_player that’s available in all your Rails templates. The code is obviously open source so if you want to take a look just head over to our GitHub Page.

Author

Daniel is an Infrastructure Architect at the video infrastructure software company, Bitmovin. Daniel is responsible for the design and operations of the encoding infrastructure, enabling complex video workflows for companies like Red Bull Media House, New York Times, Sling TV and others. Daniel has been driving Bitmovin’s migration to containerized architecture on Docker and Kubernetes.