Ooyala::Rails

Integrates Ooyala with Rails

Installation

Add the following to your application's Gemfile:

gem 'ooyala-rails'

source 'https://rails-assets.org' do
  gem 'rails-assets-jquery-ooyala'
end

And then execute:

$ bundle

Configure an initialiser like so:

# config/initializers/ooyala.rb
Ooyala::Rails.configure do |c|
  c.api_key        = 'API_KEY_GOES_HERE'    # required
  c.secret_key     = 'SECRET_KEY_GOES_HERE' # required
  c.player_id      = 'PLAYER_ID_GOES_HERE'  # optional (see below)
  c.player_options = {autoplay: false}      # optional
end

Ideally, use ENV variables instead of storing your credentials in version control.

Usage

There are two modes of use:

1. Standard

  1. Render the JS:
<!-- using configured player_id -->
<%= ooyala_js %>

<!-- specifying player_id -->
<%= ooyala_js player_id: 'PLAYER_ID_GOES_HERE' %>
  1. Render the player(s):
<!-- using configured player_id and default player options -->
<%= ooyala_player 'your_embed_code' %>

<!-- specifying player_id and player options  -->
<%= ooyala_player 'your_embed_code', player_id: 'PLAYER_ID_GOES_HERE', options: {autoplay: true} %>

2. Using jQuery

  1. Add the jquery-ooyala library to application.js:
//= require jquery-ooyala
  1. Render the players using the same arguments as with standard but using a different method:
<!-- using configured player_id and default player options -->
<%= jquery_ooyala_player 'your_embed_code' %>

<!-- specifying player_id and player options  -->
<%= jquery_ooyala_player 'your_embed_code', player_id: 'PLAYER_ID_GOES_HERE', options: {autoplay: true} %>

See jquery-ooyala documentation more functionality.

CSS

The generated container <div> will require some basic CSS, eg:

.oo-player { width:480px; height:360px; }