Functions and methods - Storm JavaScript Library

MethodReturnsReturn typeDescription
getPlayerID()Player ID (first player starts with 0, next one gets 1, etc.)numberThe method returns the player id.
getConfig()A config object provided as a first parameterObjectThe method returns the main config object that was provided to the player.
getRole()"player" or "streamer"stringThe method returns whether the player is working in the “player” or “streamer” mode (the streamer function has not been implemented yet).
getVersion()Player versionstringThe method returns player version.
initialize()-voidActivates all scripts within the player. All event-listeners should be already attached to the player.
start()-voidThe method starts the player. If “autostart” option has been selected in the config player, this method will be called automatically.
stop()-voidThis method will stop the current playback and cease all operations.
restart()-voidThe player is restarted to the default state (a combination of stop() and start() methods).
play()-voidThis method will force the player to play the specific content (if it was paused previously).
togglePlay()-voidThis method will work as a pause/play switch depending on the current player state.
isPlaying()true if player is playing a content, false otherwise.voidReturns true/false depending on current player state.
getPlaybackStatus()initialized, started, playing, paused, buffering, stoppedstringReturns current player state.
pause()-voidThis method pauses current playback.
seek(time:number)-voidSeeks stream to a given time (stream source timestamp)
mute()-voidMutes the player’s video object. It’s not the same as setVolume(0), as both methods can be applied together.
unmute()-voidThe method unmutes the player’s video object.
toggleMute()-voidSwitches mute on/off.
isMute()True if player is muted, or false if it’s notbooleanThis method can be used to check whether the player is muted.
setVolume(newVolume:int)-voidSets new volume for the player (0-100). Once the method is performed "volumeChange" event will be triggered.
setSize(width:int, height:int)-voidForces the player to resize to specific dimensions.
setWidth(width:int)-voidSets a new width for the player.
setHeight(height:int)-voidSets a new height for the player.
setScalingMode(newMode:string)-voidChanges player scaling mode. For reference, please check scaling mode in the player config.
destroy()-voidDestroys the player and removes it from the container.
addEventListener(eventName:string, callback:function, thisRef:object, priority:number, logMessage:string = "")-voidRegisters an event with the player object. Whenever a registered event occurs, player will call a predefined function provided
removeEventListener(eventName:string, callback:function)-voidRemoves event listener from the player.
getAllSources()-ObjectReturns all stream sources added to the player.
getAvailableQualities()-ObjectReturns list of all available stream qualities. Qualities are derived from streamInfo.label sources parameter.
setQuality(quality:string)-voidForces player to start the playback matching this quality (streamInfo.label source parameter).
getCurrentQuality()-stringReturns current stream quality. If streamInfo.label parameter was not defined - "none" will be returned.
addStreamSource(sourceItem:Object, addAndPlay:boolean)-stringAdd new stream object to the player. It can also start playing it automatically.
getAbsoluteStreamTime()-numberReturns stream time.
Table 1. Methods table