Ooyala Player API Reference

Overview

This document covers the various options to customize aspects of the Ooyala Player. The first section details the parameters available in the JavaScript embed code. The second and third sections provide a reference for the JavaScript and ActionScript APIs. Due to security model restrictions, the JavaScript and ActionScript interfaces are mutually exclusive with ActionScript taking precedence in the case of a conflict. The final section documents an alternative embed method for sites that do not accept JavaScript embeds.

Query String Parameter Reference

A set of parameters that can be passed to the Ooyala Player for basic customizations.

Ad Pass-Through Parameter Reference

A set of parameters that can be passed to the Ooyala Player for advanced ad tracking and targeting.

JavaScript API

A JavasScript reference for controlling the player programatically.
    JavaScript Bitrate Selection API

ActionScript 3 API

An ActionScript reference for controlling the player programatically.
    ActionScript Bitrate Selection API

HTML5 API

An HTML5 reference for controlling the player programatically.

Query String Parameter Reference

Query String Caveats

If the height is set to less than 200 or the width is set to less than 300, the controls of the player will not be exposed as the panels do not have enough space to expand.

browserPlacement displays channel controls external to the current video or channel. This makes it incompatible with view=channel and transition=selector. In the event of a conflict, browserPlacement takes precedence over those options.

Query String Examples

Standard:

<script src="http://player.ooyala.com/player.js?width=750&height=312&embedCode=dwbjp-XdAc-w6mATLnMIuwBRxHfF5vRK"></script>

Hide the sharing, info and embed buttons with channel browser on the right occupying 300px of the space:

<script src="http://player.ooyala.com/player.js?embedCode=xpaTQ6lmnTkZSM1K6tzrPAWmznGo9fON&browserPlacement=right300px&hide=sharing,info,embed&width=700&height=300"></script>

Autoplay the first video, browser on the left occupying 28% of the space:

<script src="http://player.ooyala.com/player.js?embedCode=xpaTQ6lmnTkZSM1K6tzrPAWmznGo9fON&autoplay=1&browserPlacement=left28&width=700&height=300"></script>

Ad Pass-Through Parameter Reference

The values of these parameters are tags from your ad server or ad network account and can be passed to the Ooyala Player for advanced ad tracking and targeting. Below is the list of the thruParam_ options that we currently support for ad servers and ad networks:

The example usage would look like &thruParam_<adplatform>=<value>.

Example embed string using thruParam_yume and a YuMe value:

<script src="http://player.ooyala.com/player.js?width=650&height=250&embedCode=g1Y2ljOr3HMz1rs3DiN47ihopM6XdW&thruParam_yume=ssMediaID%3tdm5iOozjsh21e8VltWXW4dPF1H8A"></script>

JavaScript API

This section of the document provides a class reference to the various get and set commands available through the JavaScript interface and example code along with a link to a live example displaying the capabilities of the API.

To enable the JavaScript API, you need to supply several parameters in the JavaScript embed snippet:

For example:


<script src="player.ooyala.com/player.js?callback=receiveOoyalaEvent&playerId=player&width=480&height=360&
embedCode=llMDQ6rMWxVWbvdxs2yduVEtSrNCJUk1"></script>

<script>
function receiveOoyalaEvent(playerId, eventName, eventParams) {
  ...
}
</script>

JavaScript Class Reference

Property

Description

getActivePanel Returns info, channels, embed or syndication if the respective panel is shown or an empty string if no panel is shown
getCanRateCurrentItem Returns whether a user is allowed to assign a rating to the current item. getCanRateCurrentItem will return false if a user previously used the current device to rate the item.
getCurrentItem Get an object describing the current video. The returned Object includes embedCode, title, description, time (play length in seconds), lineup, promo, and hostedAtURL.
getCurrentItemAverageRating Get the average rating given to the item.
getCurrentItemClosedCaptionsLanguages Get a list of supported closed captions languages for the currently playing item. This returns a list in the form of "language code" : "displayName", e.g.: { "en": "English", ... }. This list is derived from the closed captions XML file for this content, uploaded via Backlot. If there is no such file, this will return an empty list. (Note that this method will throw an exception if no Closed Captions file has been uploaded for the current embed code.)
getCurrentItemDescription Get the description of the current video
getCurrentItemEmbedCode/ setCurrentItemEmbedCode Get/set the embedCode for the current video in a channel
getCurrentItemRatings Get the rating distribution for the current item. This returns an array of integers where each integer represents the number of times a certain rating has been given to the item. For example,
[0, 16, 0, 0, 0, 0, 0, 0, 25, 0, 0]
indicates that the item has 16 votes for "1" and 25 votes for "8".
getCurrentItemTitle Get the title of the current video
getDescription Get the description of the player source
getEmbedCode/setEmbedCode Get/set the embedCode for the current player
getErrorCode Get the current error code, if one exists
getErrorText Get the current text of the error, if one exists
getFullscreen Returns true if in fullscreen mode, false if not
getItem Get an Object describing the embedded item. The Object includes embedCode, title, description, time (play length in seconds), lineup, promo, and hostedAtURL.
getLineup Get an array of objects describing the current channel
getPlayheadTime/setPlayheadTime Find where the playhead is, or move it to a new location in seconds with millisecond accuracy
getState Get current player state. One of playing, paused, buffering, channel,or error
getTitle Get the title of the current channel or video if no channel
getTotalTime Get the length of the active video (in seconds with millisecond accuracy)
getVolume/setVolume Get/set the current volume (a number between 0 and 1 inclusive)
setQueryStringParameters Set the query string parameters for the current player
setClosedCaptionsLanguage Sets the language of the closed captions which will be shown in the player. This accepts one parameter, "language", which should be an ISO 639-1 language code, e.g. "en", "de", "ja". Note that for Chinese, you should use "zh-hans" for Simplified Chinese and "zh-hant" for Traditional Chinese. To show no closed captions, set the language to be "none". (Note that this method will throw an exception if no Closed Captions file has been uploaded for the current embed code.)

Function

Description

changeCurrentItem(embedCode) Set the current video in a channel if the video is present. Returns true if accepted, false if not.
fetchMetadata(embedCode) Begins fetching the custom metadata for the given embedCode. When the metadata is fetched, the metadataReady event will be fired, which contains all of the asset's name/value pairs. This API is available to Professional and Enterprise accounts.
fetchRelatedMedia(embedCode, options) Begins fetching the related media for the given embedCode. When the related media is fetched, the relatedMediaReady event will be fired, which contains related media for the asset. Related media is specified in Backlot under the Publish->Player Branding->End Screen tab.

Options is an optional Object parameter, which can have the following fields:
  orderBy: "uploadedAt,DESC" or "uploadedAt,ASC"

For example, fetchRelatedMedia("theEmbedCode", { orderBy: "uploadedAt,DESC" }) will fetch related media for theEmbedCode with the newest video first.
getTimedText(startTime, endTime) Returns the timed text (captions) which appear between the startTime and endTime. startTime and endTime are in seconds. Note that the returned timed text will contain both the captions as well as formatting information for the captions.
getPromoFor(embedCode, width, height) Returns a promo image URL for the given embed code in a channel that will be at least the specified dimensions, or null for an embed code not present in the channel.
incrementCurrentItemRating(rating) Increments the rating for the current item. rating can be an integer from 0-10. If this computer has rated this item before, calling this function will have no effect.
loadRatingsApi() Loads the Ratings API. The Ratings API should be loaded before calling any of the ratings API functions, like incrementCurrentItemRating() and getCanRateCurrentItem(). The ratingsApiReady event will be dispatched when the API is ready for use.
pauseMovie() Pause the current video
playMovie() Play the current video
skipAd() Skip the current ad. (Note that this method will throw an exception if no ads are associated with the current embed code.)

Event notifications delivered to callback function. Please note that inter-browser compatibility issues prevent use of standard DHTML events.

Event

Parameters of the third argument to callback

Description

activePanelChanged activePanel The Info, Embed, Share or Channel panel has been exposed or hidden.
adStarted cancelable, format (e.g., "video"), source (e.g., "doubleClick"), type (e.g., "adStarted") An ad has started playing.
adCompleted cancelable, format (e.g., "video"), source (e.g., "doubleClick"), type (e.g., "adCompleted") An ad has finished playing.
adClicked cancelable, format (e.g., "video"), source (e.g., "doubleClick"), type (e.g., "adClicked") An ad has been clicked on. The event is only fired for VAST ads, Google AFV, DoubleClick, and YuMe.
apiReady The player is ready to receive API calls like playMovie(), getItem(), etc. Wait for this event to be dispatched before making any API calls.

This event is fired each time the player's embedCode is changed. The embed code can be changed via setEmbedCode() or setQueryStringParameters().

Note: Version 2 and onward.
companionAdsReady cancelable, type (e.g., "companionAds"), companionAds (ad object array; ad objects have the following properties: clickThroughURL, creativeType, resourceType, url) One or more companion ads are ready to be displayed. Only applicable to VAST compliant ads.
currentItemEmbedCodeChanged description, embedCode, hostedAtURL, lineup, promo, time (in seconds), title Current item has changed
embedCodeChanged description, embedCode, hostedAtURL, lineup, promo, time (in seconds), title Top-level player item has changed
fullscreenChanged Full-screen state has been toggled
loadComplete Player has been initialized. This is deprecated; use the apiReady event instead.
metadataReady metadata
The metadata property is an array of name/value pairs. Each name/value pair has two properties: "name" and "value". For example:
{ name: "actor", value: "Johnny Depp" }
The metadata requested by the fetchMetadata() call is now ready.
playComplete The video or channel has completed
playheadTimeChanged playheadTime The playhead has been moved
ratingsApiReady The ratings API has loaded and is now ready for use. This event is dispatched after loadRatingsApi() is called.
relatedMediaReady relatedMedia
The relatedMedia property is an array of media items. Each item has a title, description, time, promo, and embedCode.
The related media requested by the fetchRelatedMedia() call is now ready.
seeked newPlayheadTime, oldPlayheadTime A seek event happened in the player. This event can be triggerd in two ways: a user moves the scrubber bar (note the event is registered when the user releases the scrubber bar), the API call setPlayheadTime is made.
stateChanged state, errorCode, errorText The state has changed
totalTimeChanged totalTime Total time of the item has changed
volumeChanged volume The volume has changed

JavaScript Bitrate Selection API

The Bitrate Selection API allows developers to programmatically obtain current buffer size, as well as get and set bitrates. In order to select a bitrate, we offer two different workflows:

Bitrate Selection JavaScript Class Reference

Function

Description

getBufferLength() Returns the current size of the buffer in seconds, when buffer length is supported, or 0 otherwise. Currently, YouTube Assets and Remote Assets do not support buffer length.
getBitrateQualitiesAvailable() Returns an array of strings. The size of the array is dependent on the number of encodings available:
  • When only one encoding is available, the function returns [‘auto’]
  • When two encodings are available, the function returns [‘auto’,’low’,’high’]
  • When three or more encodings are available, the function returns [‘auto’,’low’, ‘medium’, ’high’]
  • When no bitrate quality information is available, the function returns [‘auto’]
getBitratesAvailable() Returns an array with the total number of bitrates, in kbps, or an empty array when the number of encodings is not available. For example, [250, 500, 1000] indicates that three bitrates are available: 250 kbps, 500 kbps and 1000 kbps.
setTargetBitrateQuality(quality) Set the target bitrate quality. One of:
  • auto: use adaptive bitrate algorithms to provide the best bitrate given the user’s current bandwidth and CPU usage
  • low: lowest bitrate available
  • medium: median of all bitrates available
  • high: highest bitrate available
Note that this setting carries over from video to video within a particular embed. For example, consider a channel with two videos, the first with highest bitrate of 1000 kpbs, and the second with medium bitrate of 1000 kpbs and highest bitrate of 2000 kpbs. If you set bitrate quality to high, the first video will play at 1000 kpbs, and the second video will play at 2000 kpbs, which is its highest bitrate.
getTargetBitrateQuality() Get the target bitrate quality. One of auto, low, medium or high.
setTargetBitrate(bitrate) Set the target bitrate, in kbps. The input needs to be an available bitrate. Available bitrates can be determined by a call to getBitratesAvailable().

Note that this setting does not carry over from video to video. For example, consider a channel with two videos, the first with highest bitrate of 1000 kpbs, and the second with medium bitrate of 1000 kpbs and highest bitrate of 2000 kpbs. If you set bitrate to 1000 kpbs, we will convert this number to a bitrate quality, which in this case in high. Since bitrate quality carries over, the first video will play at 1000 kpbs, and the second video will play at 2000 kpbs, which is its highest bitrate.
getTargetBitrate() Get the target bitrate, in kpbs, when target bitrate was previously set, or -1 otherwise.

Event

Description

targetBitrateQualityChanged The target bitrate quality has changed.
targetBitrateChanged The target bitrate has changed.
 

JavaScript Example Code

Available at http://www.ooyala.com/playerScripting-demo.html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>JavaScript Example of the Ooyala Player API</title>
</head>

<body>

<script src="http://player.ooyala.com/player.js?callback=receiveOoyalaEvent&playerId=player&width=480&height=360&embedCode=llMDQ6rMWxVWbvdxs2yduVEtSrNCJUk1&version=2"></script>
<script>

function receiveOoyalaEvent(playerId, eventName, eventArgs) {
var ciecc,ttc,ecc,vc;

  switch(eventName) {
    case "playheadTimeChanged":
      onPlayheadTimeChanged(eventArgs);
      break;
    case "stateChanged":
      onStateChanged(eventArgs);
      break;
    case "currentItemEmbedCodeChanged":
      onCurrentItemEmbedCodeChanged(eventArgs);
      ciecc=eventArgs;
      break;
    case "totalTimeChanged":
      onTotalTimeChanged(eventArgs);
      ttc=eventArgs;
      break;
    case "embedCodeChanged":
      onEmbedCodeChanged(eventArgs);
      ecc=eventArgs;
      break;
    case "volumeChanged":
      onVolumeChanged(eventArgs);
      break;
    case "apiReady": 
      //note: apiReady event has no eventArgs (3rd call-back parameter)
      onCurrentItemEmbedCodeChanged(ciecc);
      onTotalTimeChanged(ttc);
      onEmbedCodeChanged(ecc);
      break;
  }
}

function onEmbedCodeChanged(eventArgs) {
  document.getElementById("embedCode").innerHTML =
    eventArgs.embedCode + " == " + document.getElementById("player").getEmbedCode();
  document.getElementById("title").innerHTML = eventArgs.title + " == " + 
    document.getElementById('player').getTitle();
}

function onCurrentItemEmbedCodeChanged(eventArgs) {
  document.getElementById("currentItemEmbedCode").innerHTML = eventArgs.embedCode +" == " + document.getElementById("player").getCurrentItemEmbedCode();
  document.getElementById("currentItemTitle").innerHTML = eventArgs.title +" == " + document.getElementById("player").getCurrentItemTitle();
}

function onTotalTimeChanged(eventArgs) {
  document.getElementById("totalTime").innerHTML =
    eventArgs.totalTime + " == " + document.getElementById("player").getTotalTime();
}

function onPlayheadTimeChanged(eventArgs) {
  document.getElementById("playheadTime").innerHTML =
    eventArgs.playheadTime + " == "+document.getElementById("player").getPlayheadTime();
}

function onVolumeChanged(eventArgs) {
  document.getElementById("volume").innerHTML =
    eventArgs.volume + " == " + document.getElementById("player").getVolume();
}
function onStateChanged(eventArgs) {
  document.getElementById("state").innerHTML =
    eventArgs.state + " == " + document.getElementById("player").getState();
}
</script>

State <span id="state"></span>
<br>
Embed Code <span id="embedCode"></span>
<br>
Title <span id="title"></span>
<br>
CurrentItemEmbedCode <span id="currentItemEmbedCode"></span>
<br>
CurrentItemTitle <span id="currentItemTitle"></span>
<br>
Total Time <span id="totalTime"></span>

<br>
Playhead Time <span id="playheadTime"></span>
<br>
Volume <span id="volume"></span>
<br>
<button onclick="document.getElementById('player').playMovie()">Play</button>
<button onclick="document.getElementById('player').pauseMovie()">Pause</button>
<button onclick="document.getElementById('player').setPlayheadTime(document.getElementById('player').getPlayheadTime() + 30)">
+30s</button>
<br><br>
<button onclick="document.getElementById('player').setQueryStringParameters({embedCode:'8wNTqa-6MkpEB1c7fNGOpoSJytLptmm9',hide:'share,fullscreen'})">Switch Movie</button>

<%= partial :"ganalytics" %>
</body>
</html>



ActionScript 3 API

ActionScript 3 Class Reference

package com.ooyala.api

public class Player extends UIComponent

Property

Description

activePanel Bindable, read-only. Returns info, channels, embed or syndication if the respective panel is currently shown
canRateCurrentItem Whether the current computer is allowed to rate the current item. This will be false if they have rated the current item before.
closedCaptionsLanguage Sets the language of the closed captions which will be shown in the player. This accepts one parameter, "language", which should be an ISO 639-1 language code, e.g. "en", "de", "ja". Note that for Chinese, you should use "zh-hans" for Simplified Chinese and "zh-hant" for Traditional Chinese. To show no closed captions, set the language to be "none".
currentItemAverageRating The average rating given to the item.
currentItemClosedCaptionsLanguages Get a list of supported closed captions languages for the currently playing item. This returns a list in the form of "language code" : "displayName", e.g.: { "en": "English", ... }. This list is derived from the closed captions XML file for this content, uploaded via Backlot. If there is no such file, this will return an empty list.
currentItemEmbedCode Bindable, read-write. embedCode of the active video in a channel
currentItemRatings The rating distribution for the current item. This returns an array of integers where each integer represents the number of times a certain rating has been given to the item. For example,
[0, 16, 0, 0, 0, 0, 0, 0, 25, 0, 0]
indicates that the item has 16 votes for "1" and 25 votes for "8".
currentItemTitle Bindable, read-only. Title of the active video
description Bindable, read-only. The description of the player source
embedCode Bindable, read-write. embedCode of the player
errorCode Bindable, read-only. Code if the current state is error
errorText Bindable, read-only. Text if the current state is error
fullscreen Bindable, read-only. Returns true if player is in fullscreen mode, false if not.
item Bindable, read-only. Get an object describing the embedded item. The Object includes embedCode, title, description, time (play length in seconds), lineup, promo, and hostedAtURL.
lineup Bindable, read-only. An array of objects describing the current channel
playheadTime Bindable, read-write. Current playhead position in seconds with millisecond accuracy.
queryStringParameters Non-Bindable, write-only. Parameters for the object
state Bindable, read-only. Current player state. One of playing, paused, buffering, channel,or error
title Bindable, read-only. Title of the channel if there is a channel, otherwise the title of the video
totalTime Bindable, read-only. Total length of current video in seconds, with millisecond accuracy.
volume Bindable, read-write. Current volume as a number between 0 and 1 inclusive.

Function

Description

changeCurrentItem(embedCode) Set the current video in a channel if the video is present. Returns true if accepted, false otherwise.
fetchMetadata(embedCode) Begins fetching the custom metadata for the given embedCode. When the metadata is fetched, the metadataReady event will be fired, which contains all of the asset's name/value pairs. This API is available to Professional and Enterprise accounts.
fetchRelatedMedia(embedCode) Begins fetching the related media for the given embedCode. When the related media is fetched, the relatedMediaReady event will be fired, which contains related media for the asset. Related media is specified in Backlot under the Publish->Player Branding->End Screen tab.

Options is an optional Object parameter, which can have the following fields:
    orderBy: "uploadedAt,DESC" or "uploadedAt,ASC"
  
For example, fetchRelatedMedia("theEmbedCode", { orderBy: "uploadedAt,DESC" }) will fetch the related media for theEmbedCode, with the newest video first.
getTimedText(startTime, endTime) Returns the timed text (captions) which appear between the startTime and endTime. startTime and endTime are in seconds. Note that the returned timed text will contain both the captions as well as formatting information for the captions.
getPromoFor(embedCode, width, height) Returns a promo image URL for the given embed code in a channel that will be at least the specified dimensions, or null for an embed code not present in the channel.
incrementCurrentItemRating(rating) Increments the rating for the current item. rating can be an integer from 0-10. If this computer has rated this item before, calling this function will have no effect.
load() Load the Ooyala Player
loadRatingsApi() Loads the Ratings API. The Ratings API should be loaded before calling any of the ratings API functions, like incrementCurrentItemRating() and canRateCurrentItem. The ratingsApiReady event will be dispatched when the API is ready for use.
pauseMovie() Pause the current video
playMovie() Play the current video

Event

Event Trigger

activePanelChanged activePanel The Info, Embed, Share or Channel panel has been exposed or hidden.
adStarted cancelable, format (e.g., "video"), source (e.g., "doubleClick"), type (e.g., "adStarted") An ad has started playing.
adCompleted cancelable, format (e.g., "video"), source (e.g., "doubleClick"), type (e.g., "adCompleted") An ad has finished playing.
adClicked cancelable, format (e.g., "video"), source (e.g., "doubleClick"), type (e.g., "adClicked") An ad has been clicked on. The event is only fired for VAST ads, Google AFV, DoubleClick, and YuMe.
apiReady The player is ready to receive API calls like playMovie(), item, etc. Wait for this event to be dispatched before making any API calls.

This event is fired each time the player's embedCode is changed. The embed code can be changed via embedCode or queryStringParameters.
currentItemEmbedCodeChanged The embedCode of the active video has changed
embedCodeChanged Change of the player's embed code
fullscreenChanged Fullscreen state has been toggled
loadComplete The player has completed loading. This is deprecated; please use the apiReady event instead.
metadataReady The metadata requested by the fetchMetadata() call is now ready. This event has a "metadata" property which is an array of name/value pairs. Each name/value pair object has two properties: "name" and "value". For example:
{ name: "actor", value: "Johnny Depp" }
playComplete The video or channel has completed playing
playheadTimeChanged Update of active video play time
ratingsApiReady The ratings API has loaded and is now ready for use. This event is dispatched after loadRatingsApi() is called.
relatedMediaReady The relatedMedia requested by the fetchRelatedMedia() call is now ready. This event has a "relatedMedia" property which is an array of media items. Each item has a title, description, time, promo, and embedCode.
seeked newPlayheadTime, oldPlayheadTime A seek event happened in the player. This event can be triggerd in two ways: a user moves the scrubber bar (note the event is registered when the user releases the scrubber bar), the API call setPlayheadTime is made.
stateChanged Player state shift between playing, paused, buffering, or error
totalTimeChanged Change of the play length of the current video
volumeChanged The volume of the player has been changed

ActionScript Bitrate Selection API

The Bitrate Selection API allows developers to programmatically obtain current buffer size, as well as get and set bitrates. In order to select a bitrate, we offer two different workflows:

Bitrate Selection ActionScript Class Reference

Function

Description

bufferLength() Returns the current size of the buffer in seconds, when buffer length is supported, or 0 otherwise. Currently, YouTube Assets and Remote Assets do not support buffer length.
bitrateQualitiesAvailable() Bindable, read-only. Returns an array of strings. The size of the array is dependent on the number of encodings available:
  • When only one encoding is available, the function returns [‘auto’]
  • When two encodings are available, the function returns [‘auto’,’low’,’high’]
  • When three or more encodings are available, the function returns [‘auto’,’low’, ‘medium’, ’high’]
  • When no bitrate quality information is available, the function returns [‘auto’]
bitratesAvailable() Bindable, read-only. Returns an array with the total number of bitrates, in kbps, or an empty array when the number of encodings is not available. For example, [250, 500, 1000] indicates that three bitrates are available: 250 kbps, 500 kbps and 1000 kbps.
targetBitrateQuality(quality) Non-Bindable, write-only. Set the target bitrate quality. One of:
  • auto: use adaptive bitrate algorithms to provide the best bitrate given the user’s current bandwidth and CPU usage
  • low: lowest bitrate available
  • medium: median of all bitrates available
  • high: highest bitrate available
Note that this setting carries over from video to video within a particular embed. For example, consider a channel with two videos, the first with highest bitrate of 1000 kpbs, and the second with medium bitrate of 1000 kpbs and highest bitrate of 2000 kpbs. If you set bitrate quality to high, the first video will play at 1000 kpbs, and the second video will play at 2000 kpbs, which is its highest bitrate.
targetBitrateQuality() Bindable, read-only. Get the target bitrate quality. One of auto, low, medium or high.
targetBitrate(bitrate) Non-bindable, write-only. Set the target bitrate, in kbps. The input needs to be an available bitrate. Available bitrates can be determined by a call to getBitratesAvailable().

Note that this setting does not carry over from video to video. For example, consider a channel with two videos, the first with highest bitrate of 1000 kpbs, and the second with medium bitrate of 1000 kpbs and highest bitrate of 2000 kpbs. If you set bitrate to 1000 kpbs, we will convert this number to a bitrate quality, which in this case in high. Since bitrate quality carries over, the first video will play at 1000 kpbs, and the second video will play at 2000 kpbs, which is its highest bitrate.
targetBitrate() Bindable, read-only. Get the target bitrate, in kpbs, when target bitrate was previously set, or -1 otherwise.

Event

Description

targetBitrateQualityChanged The target bitrate quality has changed.
targetBitrateChanged The target bitrate has changed.

Flex ActionScript 3 API Interface


package com.ooyala.api
{
  /**
  * Player API
  */
  [Event (name="currentItemEmbedCodeChanged" )]
  [Event (name="embedCodeChanged" )]
  [Event (name="playComplete" , type="flash.events.Event" )]
  [Event (name="loadComplete" )]
  [Event (name="playheadTimeChanged" )]
  [Event (name="stateChanged" )]
  [Event (name="totalTimeChanged" )]
  [Event (name="volumeChanged" )]

  public class Player extends UIComponent
  {

    /**
    * Load the Ooyala player
    */
    public function load():void

    /**
    * Pass "query string parameters" to change the movie or channel in the player.
    * You can pass a string (similar to HTML Snippet query string
    * and FlashVars in direct Flash embed) or properties of an object
    */
    public function set queryStringParameters(parameters:*): void
    /**
    * embedCode of the player itself (in the case of a channel, will be channel)
    */
    [Bindable (event="embedCodeChanged" )]
    public function get embedCode():String
    /**
    * Convenient shortcut for set queryStringParameters('embedCode='+value)
    * i.e. Reloads movie/channel in player
    */
    public function set embedCode(value:String): void
    /**
    * Total time (in seconds) of the currently active item in the player
    * In the case of a channel, total length of the current video in the channel
    */
    [Bindable (event="totalTimeChanged" )]
    public function get totalTime():Number
    /**
    * Playhead time for the current active video in the player
    * In the case of a channel, playhead time of the current video in the channel
    */
    [Bindable (event="playheadTimeChanged" )]
    public function get playheadTime():Number
    /**
    * Seek within the active video in the channel
    */
    public function set playheadTime(value:Number): void
    /**
    * Player Volume setting
    */
    [Bindable (event="volumeChanged")]
    public function get volume():Number
    public function set volume(value:Number): void
    /**
    * The current state of the player. One of:
    * playing
    * paused
    * buffering
    * finished
    * error
    */
   [Bindable (event="stateChanged")]
   public function get state():String
   /**
   * The embedCode of the current video in the player.
   * In the case of a channel, this will be the embedCode
   * of the current video in the channel
   */
   [Bindable (event="currentItemEmbedCodeChanged" )]
   public function get currentItemEmbedCode():String
   /**
   * Play the current video or channel
   */
   public function play():void
   /**
   * Play the current video or channel
   */
   public function pause():void

  }//end of class
}

Flex ActionScript 3 Example – Getting Started

This is the first of two examples that illustrate the ability of the Ooyala player to be embedded in an Adobe Flex application using Adobe ActionScript 3. This example shows a basic integration while the following "Additional Functionality" example shows how to use more of the features exposed in the API. Sample source code, including these two examples, is available here: http://www.ooyala.com/api/ooyala_player_flex_api_demo.zip.

Please note that your player will need to target Flash 10. More information on this can be found at http://opensource.adobe.com/wiki/display/flexsdk/Targeting+Flash+Player+10.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application
  applicationComplete="player.load()"
  backgroundColor="#000000"
  layout="vertical"
  xmlns:mx="http://www.adobe.com/2006/mxml"
  xmlns:ooyala="com.ooyala.api.*"
  >
  <ooyala:Player
    id="player"
    width="100%"
    height="100%"
    embedCode="x0b2E6REM6ksHP8PMsOaWRNkq2uwLyFv"
    loadComplete="player.playMovie()"
  />
</mx:Application>

Flash ActionScript 3 Example Project

In addition to the Flex ActionScript examples, we have an Flash project example available at http://www.ooyala.com/api/ooyala_player_flash_api_demo.zip.

Flex ActionScript 3 Example – Additional Functionality


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  applicationComplete="player.load()"
  backgroundColor="#000000"
  layout="absolute"
  xmlns:ooyala="com.ooyala.api.*"
  >
  <ooyala:Player id="player" width="100%" height="100%"
    queryStringParameters="{source.selectedItem}"
    />
    <mx:HBox y="0" horizontalCenter="0"
      backgroundColor="black" backgroundAlpha="0.5"
      borderColor="white" borderStyle="solid" borderThickness="1"
      cornerRadius="10"
      paddingLeft="10" paddingTop="10" paddingRight="10" paddingBottom="10"
      >
      <mx:VBox color="white" fontWeight="bold" minWidth="150">
        <mx:Label text="Current Time: {player.playheadTime.toFixed(2)}s"/>
        <mx:Label text="Total Time: {player.totalTime}s"/>
        <mx:Label text="Volume: {(player.volume * 100).toFixed(0)}%"/>
        <mx:Label text="Play State: {player.state}"/>
      </mx:VBox>
      <mx:ComboBox id="source" selectedIndex="0" labelField="comboboxLabel">
        <mx:Array>
          <mx:Object
      comboboxLabel="Sample Video #1"
      embedCode="x0b2E6REM6ksHP8PMsOaWRNkq2uwLyFv"
      hide="sharing,fullscreen,endscreen"
          />
          <mx:Object
            comboboxLabel="Sample Video #2"
            embedCode="sxM2I6UiPuCkPaUuWM6KObYoyA-MOBcn"
            hide="info"
          />
        </mx:Array>
      </mx:ComboBox>
    <mx:Button label="Play" click="player.playMovie()"
      visible="{player.state != 'playing'}"
      includeInLayout="{player.state != 'playing'}"/>
    <mx:Button label="Pause" click="player.pauseMovie()"
      visible="{player.state == 'playing'}"
      includeInLayout="{player.state == 'playing'}"/>
    <mx:Button label="seek -30s" click="player.playheadTime -= 30"/>
    <mx:Button label="seek +30s" click="player.playheadTime += 30"/>
    <mx:Button label="volume 25%" click="player.volume = 0.25"/>
  </mx:HBox>
</mx:Application>

Player Object Embed Code

For situations where JavaScript embeds are not accepted, such as certain blog or social networking sites, we offer this as an example of using object embed code to include the Ooyala player. We recommend using the JavaScript embed wherever possible. The object embed code removes the ability for viewers to be automatically upgraded to the latest Flash version along with a lack of support for the JavaScript API covered earlier in this document.


<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="ooyalaPlayer" width="640" height="480"
 codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value=" http://player.ooyala.com/player.swf" />
<param name="bgcolor" value="#000000" />
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="true" />
<param name="flashvars" value="embedCode=9qbTrtNmh_YxuWN7ifQ38ttUkska9UF4" />
<embed src="http://player.ooyala.com/player.swf" bgcolor="#000000" width="640" height="480"
name="ooyalaPlayer"
align="middle" play="true" loop="false"
allowscriptaccess="always" type="application/x-shockwave-flash"
allowfullscreen="true"
flashvars="embedCode=9qbTrtNmh_YxuWN7ifQ38ttUkska9UF4"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>

HTML5 API

This section describes how to customize the playback experience on HTML5 devices, including iOS devices. The HTML5 API provides some of the most commonly used API calls for HTML5 playback: play, pause, seek, and change embedCode. Note that iOS devices only support user-initiated actions. For example, a video can only play when a user clicks a UI element such as a play button; videos cannot play automatically.

To enable the API, you need to supply several parameters in the JavaScript embed snippet:

For example:


<script src="http://player.ooyala.com//player.js
?width=608
&callback=playerAPICallback
&embedCode=s0MmVvMTrSlB1ZLzaWXnKZaa42Ib5rJV
&height=342
&playerId=ooplayer">
</script>

HTML5 Class Reference

Function

Description

pauseMovie() Pause the current video
playMovie() Play the current video
setEmbedCode Set the embedCode for the current player
setPlayheadTime Set the playhead to a new location in seconds with millisecond accuracy

HTML5 Demo

Available at http://www.ooyala.com/html5-demo.html


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">

            <title>Test HTML5 Player for iOS</title>

            <script type="text/javascript" src="http://www.ooyala.com/nuplayer/jquery.js"></script>
            <script type="text/javascript" charset="utf-8">
    var skipStartScreen = false;

    function get_player() {
      return document.getElementById('ooplayer');
    }
    function play() {
      get_player().playMovie();
    }
    function pause() {
      get_player().pauseMovie();
    }
    function setPlayheadTime() {
      get_player().setPlayheadTime($('#playhead_time').val());
    }
    function setEmbedCode() {
      get_player().setEmbedCode($('#embed_code').val());
    }

  </script>

    </head>

    <body>
        <div id="player_controls">
            <input type=button value="Play" onclick="play()"/>
            <input type=button value="Pause" onclick="pause()"/>
            <input type=button value="Set Playhead Time" onclick="setPlayheadTime()"/>
            <input type=text size="5" id="playhead_time"/>
            <input type=button value="Change Embed Code" onclick="setEmbedCode()"/>
            <input type=text size="40" id="embed_code"/>
        </div>


        <div id="player-box">
            <div id="drag-handle"> </div>


            <script src="http://player.ooyala.com//player.js?width=608&embedCode=s0MmVvMTrSlB1ZLzaWXnKZaa42Ib5rJV&height=342&playerId=ooplayer"></script>


            <div id="dimensions"></div>
        </div>
    </body>
</html>