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") %>
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.