---
title: "JavaScript SDK Reference"
slug: "javascript-sdk-reference"
updated: 2024-04-17T13:49:20Z
published: 2024-04-17T13:49:20Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://help.tritondigital.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JavaScript SDK Reference

This section describes all of the JavaScript methods available in the SDK.

| player.version |
| --- |
| Return the Triton Digital Web Player SDK version **console.log(player.version)** |

| player.play( params ) |
| --- |
| Start the playback of a live audio/video stream. The **autoplay** feature is disabled on mobile (iOS, Android) with HTML5. For related information, see [Using Auto-play](/v1/docs/using-auto-play). Parameters: **params**(object). Required: Yes. The playback configuration object **Properties:** **station**(String) or**mount**(String). Required: Yes. The station on the Triton Digital platform. Example: TRITONRADIOMUSIC Mount on the Triton Digital platform. Example: TRITONRADIOMUSICAAC **connectionTimeOut**(Number). Required: No. Duration of the Live Stream Connection before timing out (minutes) - default value is 0 (de-activated). When a**connectionTimeOut**value is defined, after "connectionTimeOut" minutes, the controller sends a "timeout-alert" event that the stream will stop. When receiving that alert, the website developer (client side) should display a message to the user, such as: “To keep the connection alive, please click here or the stream will stop.” The user can continue to listen to the live stream by clicking on this message: the website developer (client side) needs to call the function**restartConnectionTimeOut()**(see below) and hide the message. If the user does not click on the message, then 30 seconds after the alert is displayed, the stream will automatically stop.The controller sends a "timeout-reached" event. If the user wants to listen again to the stream, the website developer (client side) needs to display another message. For example: "The stream was stopped (connection time out occurred). To listen again to the live stream, please click here. Thank you." When the user clicks on this message, the website developer (client side) need to call the function**play()**and hide the message. **timeShift**(Boolean). Required: No. Set to **true** to enable client-side [Timehift Radio](/v1/docs/using-timeshift-radio). Set to **false** to disable TimeShifting. Default value is **false**. Create a**player.seek()**heading. (Only applicable for Timeshift enabled mounts.) - Use to seek **forward** and **backward**. e.g.:**seek(10), seek(-10)** Create a**player.seekLive()**heading. (Only applicable for Timeshift enabled mounts.) - Use to seek to the **live position** in the stream. **trackingParameters**(Object). Required: No. The**trackingParameters**values are appended to the stream URL. They are used to log information from player. Example: **player.play( {** **station: 'STATION_NAME',** **trackingParameters: {** **dist: 'triton',** **KEY2: 'value2',** **KEY3: 'value3'** **}** **} );** *Example*: Play the **TRITONRADIOMUSIC** station stream: **player.play( {station: 'TRITONRADIOMUSIC'} );** *Example*: Play the **TRITONRADIOMUSICAAC** mount stream: **player.play( {mount: 'TRITONRADIOMUSICAAC'} );** *Example*: Play the **TRITONRADIOMUSIC** station stream with the connection timeout set to **60** minutes and the TimeShifting enabled. **player.play( {station: 'TRITONRADIOMUSIC', connectionTimeOut:60, timeShift:true} );** |

| player.pause() |
| --- |
| Stop the stream. Functions the same as**player.stop()** **player.pause();** |

| player.stop() |
| --- |
| Stop the stream. **player.stop();** |

| player.resume() |
| --- |
| Start the stream. Functions the same as**player.play()** **player.resume();** |

| player.restartConnectionTimeOut() |
| --- |
| Restart the connection timeout. Please refer to the**play()**function documentation (parameter**connectionTimeOut**). **player.restartConnectionTimeOut();** |

| player.changePlayBackRate(rate) |
| --- |
| Change the podcast playback speed. The rate value is a float, with a value between **0** and **infinity**. **Examples**: If the value changes to **2** then the speed is doubled. If the value changes to **0.5** then it plays at half speed. |

| player.setVolume( volumePercent ) |
| --- |
| Sets the controller's audio/video volume *Not supported: iOS, Android due to built-in limitations.* **Definition** **volumePercent**(Number). Required: Yes The new volume percentage between 0 and 1. Example: 0.75 for 75% Example: **player.setVolume(1);** |

| player.getVolume |
| --- |
| Return the current volume Not supported: iOS, Android, because the audio level is always under the user’s physical control on mobile. **player.getVolume();** |

| player.mute() |
| --- |
| Stop the stream. Functions the same as**player.stop()** **player.mute();** |

| player.unMute() |
| --- |
| Start the stream. Functions the same as**player.play()** **player.unMute();** |

| player.playAd( adServerType, config ) |
| --- |
| Play an ad (audio/video) - can be used for preroll, midroll, postroll. **Definition** **adServerType**(String). Required: Yes. The adServerType defines which Ad Plugin to use, possible values are: - vastAd: The **vastAd** plugin is required in the configuration to use this feature. - tap: The **tap** plugin is required in the configuration to use this feature. - mediaAd: The **mediaAd** plugin is required in the configuration to use this feature. **adConfig**(Object). Required: Yes. For adServerType**vastAd**, adConfig properties are: - **adConfig.sid** (integer) - TritonRunSpot Station Id - If value is set, the TritonRunSpot API is called. - **adConfig.mediaformat**(integer) - Optional value for TritonRunSpot API content format. The default value is 21. *or* - **adConfig.url** - If value is set, the VAST Ad URL is called by using adConfig.url. - **adConfig.rawXML**- If value is set, the VAST Ad response (pre-parsed XML) is used by using adConfig.rawXML. If **both****adConfig.url**and**adConfig.sid**are set in the adConfig object, **the sid is used** **by default**. For adServerType **tap**, adConfig properties are: - **adConfig.host**(String) - Host name to use for on-demand ad requests. Required : yes. - **adConfig.type**(String) - Ad type. Valid values : preroll or midroll. Required : yes. - **adConfig.format**(String) - Rendering format. Valid values : vast, vast-jsonp, daast. Required : No. Default : vast. - **adConfig.stationName**(String) - Station Name. Required : yes. - **adConfig.stationId**(integer) - Station ID. Required : yes. - **adConfig.maxAds**(integer) - Maximum number of ads. Required : no. - **adConfig.assetType**(String) - Asset Type. Required : no. - **adConfig.minFileSize**(integer) - Minimum size. Required : no. - **adConfig.maxFileSize**(integer) - Maximum size. Required : no. - **adConfig.fileFormat**(String) - File format. Comma-separated list of: mp3, adts, flv, mp4, ogg. Required : no. - **adConfig.minDuration**(integer) - Minimum duration. Required : no. - **adConfig.maxDuration**(integer) - Maximum duration. Required : no. - **adConfig.minBitrate**(integer) - Minimum bitrate. Required : no. - **adConfig.maxBitrate**(integer) - Maximum bitrate. Required : no. - **adConfig.minWidth**(integer) - Minimum width. Required : no. - **adConfig.maxWidth**(integer) - Maximum width. Required : no. - **adConfig.minHeight**(integer) - Minimum height. Required : no. - **adConfig.maxHeight**(integer) - Maximum height. Required : no. - **adConfig.audioCodec**(String) - Audio codec. Required : no. - **adConfig.audioMinChannels**(integer) - Minimum chanels. Required : no. - **adConfig.audioMaxChannels**(integer) - Maximum chanels. Required : no. - **adConfig.audioSampleRates**(String) - Audio samples rates. Required : no. - **adConfig.videoCodec**(String) - Video codec. Required : no. - **adConfig.videoAspectRatio**(String) - Aspect radio. Required : no. - **adConfig.minFrameRate**(integer) - Minimum frame rate. Required : no. - **adConfig.maxFrameRate**(integer) - Maximum frame rate. Required : no. - **adConfig.excludedCategories**(String) - Excluded categories. Only available with Triton Digital SSP/Exchange ads. Required: no. **Note:** Either the Station ID or station name must be specified when calling the On-Demand Ad Request Service. While both IDs and names are supported, it is strongly recommended that you use **station names**. If both ID and name are provided, the name is used (*there is no validation check that the ID matches the name*). For adServerType **bloom**, adConfig properties are: - **adConfig.id**- The mandatory BloomAd Spot ID, must be a Media Ad type only (i.e. video/audio file). Bloom companion banners are NOT managed by the Player SDK, they should be loaded within an iFrame in JavaScript. For adServerType**mediaAd**, adConfig properties are: - **adConfig.mediaUrl**String - video/audio media ad file to play. - **adConfig.linkUrl**String - associated link with the media ad. **trackingParameters**property may be used to pass targeting information to the Ad server. **volume**property may be useful to define volume level of Ad playback. Examples: ```javascript //VAST Ad full URL playAd( 'vastAd', { url: 'http://runspot4.tritondigital.com/RunSpotV4.svc/GetVASTAd?&StationID=8441&MediaForm at=21&RecordImpressionOnCall=false&AdMinimumDuration=0&AdMaximumDuration=900&AdLevel Placement=1&AdCategory=1' } ); //Call Triton Ad Platform (TAP) player.playAd( 'tap', { host:'cmod.live.streamtheworld.com', type:'preroll', format:'vast', stationId:77583 } ); //Call TritonRunSpot V 4.0+ (Campaign manager) VAST Ad Preroll with preroll-synced banner. sid (integer) is the TritonRunSpot Station ID (required). playAd( 'vastAd', { sid: 8441 } ); //Call Media Ad player.playAd( 'mediaAd', { mediaUrl: 'http://cdnp.tremormedia.com/video/acudeo/Carrot_400x300_500kb.flv', linkUrl:'http://www.google.fr/' } ); //Call Bloom Ad Spot id player.playAd( 'bloom', { id: 4974 } ); //Call with trackingParamters. TritonRunSpot V 4.0+ (Campaign manager) VAST Ad Preroll with preroll-synced banner. sid (integer) is the TritonRunSpot Station ID (required). player.playAd( 'vastAd', { sid: 8441, trackingParameters:{banners:300x250} } ); ``` |

| player.skipAd() |
| --- |
| Skip the current ad **player.skipAd();** |

| NowPlayingApi.load( {**mount:mount**, **hd:true**, numberToFetch:10, eventType:'track', } ) |
| --- |
| Load the Now Playing history **mount**(String). Required: Yes. The Station mount on the Triton Digital platform. **hd**(Boolean). Required: No. Default false. Set true if the mount has AAC. **numberToFetch**(Number). Required: No. Number of elements to fetch **eventType**(String). Required: No. Default 'track' **player.NowPlayingApi.load({mount:'STD_PLAYER_DEMO1', hd:true, numberToFetch:10});** |
