Class: KalturaPlayerAPI

KalturaPlayerAPI()

KalturaPlayerAPI class with methods of checking script state and embed media meta data and api data

In order to set the Partner ID/UIConf ID, set the following environment variables:

  • KALTURA_PARTNER_ID
  • KALTURA_UICONF_ID

Constructor

new KalturaPlayerAPI()

Source:

Methods

(async, static) api(mediaId) → {object}

Gets the api data

Parameters:
Name Type Description
mediaId string

The mediaId we're embedding the placeholder for.

Source:
Returns:

object

Type
object
Example
import { KalturaPlayerAPI } from '@carbon/ibmdotcom-services';

async function getMyVideoInfo(id) {
  const data = await KalturaPlayerAPI.api(id);
  console.log(data);
}

(static) checkScript() → {Promise.<*>}

Gets the full _scriptReady state

Source:
Returns:

Promise kaltura media player file

Type
Promise.<*>

(async, static) embedMedia(mediaId, targetId, flashvars, useIbmMetrics, customReadyCallback) → {object}

Gets the embed meta data

Parameters:
Name Type Default Description
mediaId string

The mediaId we're embedding the placeholder for.

targetId string

The targetId the ID where we're putting the placeholder.

flashvars object

Determine any extra param or plugin for the player.

useIbmMetrics boolean true

Whether or not should IBM Metrics events be fired.

customReadyCallback function

Determine any extra functions that should be executed on player readyCallback.

Source:
Returns:

object

Type
object
Example
import { KalturaPlayerAPI } from '@carbon/ibmdotcom-services';

function embedMyVideo() {
  const elem = document.getElementById('foo');
  const videoid = '12345';
  KalturaPlayerAPI.embedMedia(videoid, elem);
}

(static) fireEvent(param)

Fires a metrics event when the media was played. Pass events to common metrics event.

Parameters:
Name Type Description
param object

params

Properties
Name Type Description
playerState number

state detecting different user actions

kdp object

media object

mediaId string

id of the media

customMetricsData object

any extra parameter for custom events

Source:

(static) getMediaDuration(duration, fromMilliseconds) → {string}

Convert media duration from milliseconds and seconds to HH:MM:SS

Parameters:
Name Type Default Description
duration string 0

media duration in seconds

fromMilliseconds boolean

the duration argument is expressed in milliseconds rather than seconds

Source:
Returns:

converted duration

Type
string

(static) getThumbnailUrl(params) → {string}

Creates thumbnail image url with customizable params

Parameters:
Name Type Description
params object

param object

Properties
Name Type Description
mediaId string

media id

height string

specify height in pixels

width string

specify width in pixels

Source:
Returns:

url of thumbnail image

Type
string
Example
import { KalturaPlayerAPI } from '@carbon/ibmdotcom-services';

function thumbnail() {
  const thumbnailData = {
     mediaId: '1_9h94wo6b',
     height: '240',
     width: '320'
  }
  const thumbnailUrl = KalturaPlayerAPI.getThumbnailUrl(thumbnailData);
}