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. 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. 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( { player.play( {station: 'TRITONRADIOMUSIC'} ); Example: Play the TRITONRADIOMUSICAAC mount stream:player.play( {mount: 'TRITONRADIOMUSICAAC'} ); |
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:
adConfig (Object). Required: Yes. For adServerType vastAd, adConfig properties are:
or
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:
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:
For adServerType mediaAd, adConfig properties are:
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:
|
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}); |