# interface IPlayerApi

#### package com.turner.top.sdk.core.api

The entry point for the player sdk.

### Methods

###

`addCue (cue:Dynamic):IPlayerApi`

Adds a cue that can be triggered based on the given data.

Parameters:

`cue` | Can be one of three types: Cue, ExternalCue, or CueNotification

###

`attach (viewElement:NativeViewElement):IPlayerApi`

Add the video player to the DOM.

Note: Must wait for the playerInitialized event to have fired before calling

Parameters:

`viewElement` | The DOM element to add the video player to.

See:

PlayerInitConfigData.element

###

`canAutoPlay ():Promise<Bool>`

Whether or not autoPlay is possible for the current browser or device. Takes into account whether the video element is primed (user has interacted with the page).

Returns:

Promise<Bool>

###

`destroy ():Void`

Kill the player

Returns:

Bool

###

`detach ():IPlayerApi`

Remove the video player from the DOM

###

`element ():NativeViewElement`

Returns the player container

Returns:

NativeViewElement

###

`enterFullscreen ():IPlayerApi`

Enters fullscreen

###

`events ():PlayerApiEvents`

The events collection for player sdk

###

`exitFullscreen ():IPlayerApi`

Exits fullscreen

###

`init (initConfigData:PlayerInitConfigData):IPlayerApi`

Initialize the player.

Parameters:

`initConfigData` | Defines default values for player configuration

###

`isAdActive ():Bool`

Checks if the player is executing the ad flow

Returns:

Bool

###

`isContentActive ():Bool`

Checks if the player is in the process of setting up or playing content

Returns:

Bool

###

`isFullscreen ():Bool`

Checks if the player is fullscreen

Returns:

Bool

###

`isInitialized ():Bool`

Checks if the player is initialized

Returns:

Bool

###

`isMediaActive ():Bool`

Checks if the player is executing the media flow

Returns:

Bool

###

`isReady ():Bool`

Checks if the player is ready

Returns:

Bool

###

`model ():IPlayerModel`

The model for the player sdk

###

`mute ():IPlayerApi`

Turn sound off

###

`pause ():IPlayerApi`

Pause content playback

###

`play (data:ContentPlayData, ?options:Dynamic):IPlayerApi`

Play specified content.

Parameters:

`data` | Info about the content to play.
`options` | Optional data to pass for the specific play. See Integration - Play Options

Returns:

IPlayerApi

See:

Integration - Play Media Inline

###

`playByContentXml (data:ContentProviderData, ?options:Dynamic):IPlayerApi`

Play content via content.xml

Parameters:

`data` | Info about the content to play. Below are properties that can be set on data:
Name | Description | Type | Required | Default
--- | --- | --- | --- | ---
    url
| The url of the content.xml file to load |
    String
| Yes | none
    selectFile
| A filter function whose logic determines which file data under the <files> node will be added to the resulting entry data. See ContentEntryFileData for more on fileData (see example) |
    Function
| No |
    function(fileData) {
      return true;
    }
    parseC5asC4
| Configuration option for parsing <adBlocks>. Supported options are: true - Converts the <adBlocks> data to be used as C4 <segments> false - Currently unsupported |
    Bool
| No |
    true
`options` | Optional data to pass for the specific play. See Integration - Play Options

Returns:

IPlayerApi

See:

Integration - Content Xml

###

`playByMediaJson (data:ContentProviderData, ?options:Dynamic):IPlayerApi`

Play content via mediaJson

Parameters:

`data` | Info about the content to play. Below are properties that can be set on data:
Name | Description | Type | Required | Default
--- | --- | --- | --- | ---
    mediaId
| ID for specific content to play |
    String
| Yes | none
    host
| The host address to load media.json data |
    String
| No |
    'http://medium.ngtv.io/media'
    mediaTypes
| Media file types to use. The first type found will be used to play content |
    Array
| No |
    ['bulkaes', 'unprotected']
    platform
| Device for which content is retrieved |
    String
| No |
    'desktop'
    serviceUrl
| The media.json url template (tokens replaced with configured values on data) |
    String
| No |
    '{host}/{mediaId}/{platform}'
`options` | Optional data to pass for the specific play. See Integration - Play Options

Returns:

IPlayerApi

See:

Integration - Media Json

###

`proceed ():IPlayerApi`

Allow the player to play content if it's configured to not auto play and in a waiting state.

See:

PlayerApiEvents.contentWaiting
PlayerConfigPlayerData.autoPlay

###

`ready (cb:Void ‑> Void):IPlayerApi`

Executes the given callback once the player is in a ready state.

Parameters:

`cb` | The callback to invoke

###

`removeCue (cue:Dynamic):IPlayerApi`

Removes a cue that can be triggered based on the given data.

Parameters:

`cue` | Can be one of three types: Cue, ExternalCue, or CueNotification

###

`replay ():IPlayerApi`

Play the same content again

###

`reportError (event:AnalyticsErrorData):IPlayerApi`

Api for reporting errors to any configured analytics libraries

Parameters:

`event` | Contains the error data to report to all analytics libraries

###

`reportEvent (event:AnalyticsEventData):IPlayerApi`

Api for reporting events to any configured analytics libraries

Parameters:

`event` | Contains the event data to report to all analytics libraries

###

`resize (width:Float, height:Float):IPlayerApi`

Change the dimensions of the player

Parameters:

`width` | In pixels
`height` | In pixels

###

`resume ():IPlayerApi`

Resume content playback

###

`seek (time:Float):IPlayerApi`

Seek content to specified position

Parameters:

`time` | The time in seconds between 0 and the length of the content

###

`seekToLive ():IPlayerApi`

Seek to the live point in a live stream

###

`selectCaptionTrack (track:CCTrack):IPlayerApi`

Specify which closed caption track instance to use. Note, this method will auto-enable closed captions for the player.

Parameters:

`track` | The closed caption track to select

###

`selectCaptionTrackByLang (lang:CCLang):IPlayerApi`

Specify which closed caption track to use by language. Note, this method will auto-enable closed captions for the player.

Parameters:

`lang` | The language of the track to select

###

`setCaptionsEnabled (enabled:Bool):IPlayerApi`

Set whether closed captions are enabled or disabled. Note, a track must be selected for this to take effect.

Parameters:

`enabled` | true to enable captions

###

`setVolume (volume:Float):IPlayerApi`

Set content volume

Parameters:

`volume` | A value between 0 and 1

###

`stop ():IPlayerApi`

Stop content playback and prevent further buffering

###

`uniqueId ():Null<String>`

Returns a unique ID representing the page hostname, player container ID and the timestamp in which the player instance was initialized.

Returns:

Null<String>

###

`unmute ():IPlayerApi`

Turn sound on

###

`updateCaptionSettings (settings:CCSettings):IPlayerApi`

Set the styles for closed captions.

Parameters:

`settings` | Defines how to style captions

###

`updateConfig (data:PlayerConfigData):IPlayerApi`

Override the player configuration data after the player has been initialized. Overridden properties will be applied to currently playing content when possible and will be applied to subsequent content during the lifetime of the player.

Parameters:

`data` | Data used to override current player configuration

Returns:

IPlayerApi

###

`userAction (?result:Event):IPlayerApi`

Registers a user action on the player. Primes the video ahead of time, which will allow it to be played without a user interaction later in browsers which block auto play.

Parameters:

`result` | The default JavaScript HTML Event result returned from event callbacks

Returns:

IPlayerApi

See:

AutoPlay - Click to Play