Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including videojs-ooyala with all npm packages installed. Try it out:

videojs-ooyala lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("videojs-ooyala/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

videojs-ooyala v0.3.2

Video.js plugin to fetch videos from Ooyala

videojs.ooyala.js

Video.js plugin to fetch videos from Ooyala. By supplying an Ooyala EmbedCode, the plugin will call the Ooyala API and fetch the video source of that EmbedCode.

Demo

Run grunt on the project folder will serve up a server at localhost:3000/demo which provides a demo page.

Usage

Include ./dist/videojs.ooyala.js after video.js.

Enable the plugin once your player has been initialised:

player.ooyala({
    playerBrandingId: (String), // Ooyala Player Branding ID (Required)
    pcode: (String),             // Ooyala Provider ID (Required)
    enableHls: (Boolean),        // Tweak force returning m3u8 from Ooyala if available (Optional)
    mobileProfile: (String)     // SAS profile to narrow down streams for mobile devices (Optional)
});

Set an Ooyala video to the player:

If you want to set an Ooyala video to the player and prepare it for playback:

player.ooyala.setSource(embedCode, callback);
// embedCode: (String) The Ooyala video EmbedCode (Required)
// callback: (Function) Returns the results of getVideoSource(), see below (Optional).

Get video source from Ooyala

If you need to get the video source from ooyala for other use:

player.ooyala.getVideoSource(embedCodes, callback);
// embedCodes: (String/Array) The Ooyala video EmbedCodes. Can be multiple videos. (Required)
// callback: (Function) Callback function once data is fetched. (Required)

Callback function will have err and res as argument, here is an example of callback results:

{
    apiResponse: 'the complete response from the Ooyala API as a JSON object'
    videoUrls: {
        embedCode1: {
                authorized: 'true',         // If we are authorised to use this video
                src: 'Video URL',           // If authorised is true, this is defined.
                type: 'Video Type'          // If authorised is true, this is defined.
        },
        embedCode2: {
                authorized: 'false',
                message: 'Error Message',   // If authorised is false, this is defined.
                code: 'Error Code'          // If authorised is false, this is defined.
        }
    }
}

src and type are only set if authorized is true. You can then set these to the player, for example:

player.ooyala.getVideoSource('myEmbedCode1, myEmbedCode2', function(err, res) {
    var videoResult = res && res['myEmbedCode1'];

    if (videoResult.authorized) {
      player.src({
          type: videoResult.type,
          src: videoResult.src
      });
    }
})

Get the meta data of an Ooyala video

Ooyala videos have meta data that we can extract based on the embedCode.

player.ooyala.getMetadata(embedCode, callback)
// embedCodes: (String/Array) The Ooyala video EmbedCodes. Can be multiple videos. (Required)
// callback: (Function) Callback function once metadata is fetched (Required)

Example:

player.ooyala.getMetadata(embedCode, function(err, res) {
    console.log('metadata', embedCode, res);
})

Player support

This plugin has been tested with:

  • Video.Js 4.12.15
  • Brightcove Perform Player v1.24.22

IE Browser compatibility

This plugin uses the following functions so if you need support for a particular version of IE, you will need to implement a polyfill within your application.

FunctionIE Version Supported
Object.keysIE9+
window.atobIE10+

Contributing

Bug fixes are always welcome, though for new functionality it's best to raise an issue first. We appreciate that all contribution follow our style guide set in our JSHint and JSCS using Grunt.

History

v0.3.0

  • Retry XHR calls on timeout
  • Add video.js error messages on failed XHR calls

v0.2.0

  • Add enableHls and mobileProfile option.
  • Add prepareSettingSource() to allow developer to prepare video source before setting to video player.

v0.1.0

  • First release
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free