Embed Code JavaScript APIs (Player V2 Deprecated)

Embed Code JavaScript APIs can be used to handle getting and setting embedCode for assets, getting asset descriptions, getting images and fetching metadata for assets.

EmbedCode Properties

Note: Ooyala Player V2 has been deprecated and is scheduled to be disabled. For details and alternatives, see the OVP Release Notes.

The following table describes all the JavaScript properties that are associated with embed code.

Function Description
SetEmbedCode

Set the embedCode for the current player.

Type: String

getCurrentItemEmbedCode

Get/set the embedCode for the current video in a channel.

Type: String

getEmbedCode

Get the embedCode for the current player.

Type: String

getItem

Get an Object describing the embedded item.

Type: Object

Return Value: Object. The Object includes the embedCode, title, description, time (play length in seconds), lineup, promo, and hostedAtURL.

setCurrentItemEmbedCode Set the embedCode for the current video in a channel. Type: String

EmbedCode Functions

The following table describes all the JavaScript methods that are associated with embed code.

Event Description
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.

Type: String

Valid Value: Specify an embed code string.

Return Values: name/value pairs

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.

Type: String

Valid Values: Specify an embedCode, plus a width and height.

Return Value: URL | null

changeCurrentItem(embedCode)

Set the current video in a channel if the video is present. Returns true if accepted, false if not.

Type: Boolean

Valid Values: true | false

currentItemEmbedCodeChanged( )

description, embedCode, hostedAtURL, lineup, promo, time (in seconds), title.

Type: Hash

embedCodeChanged( )

description, embedCode, hostedAtURL, lineup, promo

Type: Hash

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 that can have the following fields:

  • orderBy:
  • uploadedAt,DESC
  • uploadedAt,ASC

Example

The following example will fetch related media for theEmbedCode with the newest video first.
fetchRelatedMedia("theEmbedCode", { orderBy: "uploadedAt,DESC" })

Related Information

The following list provides links to Backlot documentation that provides some general information about embed code and embed code snippets.

Was this article helpful?