Functions and methods - Storm JavaScript Library

MethodReturnsReturn typeDescription
initialize()-voidActivates all scripts within the player. All event-listeners should be already attached to the player.
getPlayerID()Player ID (first player starts with 0, next one gets 1, etc.)numberMethod returns the player id.
getConfig()A config object provided as a first parameterObjectThis method returns the main config object that was provided to the player.
getRole()"player" or "streamer"stringThis method returns whether the player is working in the “player” or “streamer” mode (the streamer function has not been implemented yet).
getVersion()Player versionstringThis method returns player version.
play()-voidThis method will force the player to play the specific content (if it was paused previously).
pause()-voidThis method pauses current playback.
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).
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.
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.
getVolume()Current volume levelnumberReturns player volume (0-100).
setSize(width:int, height:int)-voidForces the player to resize to specific dimensions.
setWidth(width:int)-voidSets a new width for the player.
getWidth()Player widthnumberReturns Player width
setHeight(height:int)-voidSets a new height for the player.
getHeight()Player heightnumberReturns Player height
setScalingMode(newMode:string)-voidChanges player scaling mode. For reference, please check scaling mode in the player config.
getScalingMode()Current scaling modestringCurrent 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()Object containing available qualities (their labels)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()Label for current stream qualitystringReturns 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()UnixtimenumberReturns stream time.
Table 1. Methods table