API Methods - Storm JavaScript Library

Method nameReturnsReturn typeDescription
initialize()-voidActivates all scripts within a library instance. All event-listeners should be already attached to the library.
isInitialized()true if this library instance was already initialized.booleanReturns true if this library instance has already been initialized.
getLibraryID()Library ID (first instance starts with 0, next one gets 1, etc.)numberThis method returns library's ID.
getRole()player or streamerstringThis method returns whether the library is working in the player or streamer mode (the streamer function has not been implemented yet).
getVersion()Library version in xx.xx.xx format.stringThis method returns library version.
play()-voidThis method will initiate playback of a video stream. If a video was paused or stopped previously, you can use this method to resume playback.
pause()-voidThis method pauses current playback.
stop()-voidThis method pauses current playback. This method will stop the current playback and cease all operations. It'll also disconnect library from a server.
restart()-voidThe library 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 object state.
isPlaying()true if playback is active.booleanReturns true/false depending on current library state. Please check “getPlaybackState()” for more detailed information.
getPlaybackState()"NOT_INITIALIZED", "INITIALIZED", "PLAYING", "PAUSED", "BUFFERING", "STOPPED", "UNKNOWN"stringReturns current library state.
getStreamState()"AWAITING", "NOT_PUBLISHED", "UNPUBLISHED", "PUBLISHED", "CLOSED", "UNKNOWN"stringReturns current stream state.
seek(time: number)-voidSeeks stream to a given time (stream source timestamp).
mute()-voidMutes the library’s video object. It’s not the same as setVolume(0), as both methods can be applied together.
unmute()-voidThe method unmutes the library’s video object.
toggleMute()-voidSwitches mute on/off.
isMute()true if the library is muted.booleanThis method can be used to check whether the library is muted.
setVolume(newVolume: number)-voidSets new volume for the library (0-100). Once the method is performed volumeChange event will be triggered.
getVolume()Current volume level 0-100numberReturns library volume (0-100).
setSize(width: number | string, height: number | string)-voidThe method sets a new width and height for the video element. The values can be given as a number (in which case they are treated as the number of pixels), or as a string ending with "px" (this will also be the number of pixels) or "%", where the number is treated as a percentage of the parent container's value.
setWidth(width: number | string)-voidThe method sets a new width for the video element. The value can be given as a number (in which case it is treated as the number of pixels), or as a string ending with "px" (this will also be the number of pixels) or "%", where the number is treated as a percentage of the parent container's value.
getWidth()Video Object widthnumberReturns main Video Object width in pixels.
setHeight(height: number | string)-voidThe method sets a new height for the video element. The value can be given as a number (in which case it is treated as the number of pixels), or as a string ending with "px" (this will also be the number of pixels) or "%", where the number is treated as a percentage of the parent container's value.
getHeight()Video Object heightnumberReturns main Video Object height in pixels.
setScalingMode(newMode: string)-voidChanges library scaling mode. For reference, please check scaling mode in the library config.
getScalingMode()Current scaling modestringReturns current library scaling mode. For reference, please check scaling mode in the library config.
setStreamConfig(config: StormStreamConfig)-voidSets stream config for the library (or overwrites an existing one).
getStreamConfig()Storm Streaming Configuration objectStormStreamingConfigReturns current config for the library.
destroy()-voidDestroys the library instance and removes it from the container.
addEventListener(eventName: string, callback: function, removable: boolean = true)-voidRegisters an event with a library instance. Whenever a registered event occurs, the library will call a provided function.
removeEventListener(eventName: string, callback: function)-voidRemoves event listener from the library. If callback is not provided all events of that type will be removed.
removeAllEventListeners()-voidRemoves all removable event listener from the library.
getSourceList()Array containing available sources.ISourceItem[]Returns an array of all available source items.
removeAllSources()-voidRemoves all SourceItems from a library instance. This method however will not stop current playback.
gatewayRequest(streamKey: string)-voidThis method will create a new request to a Storm Streaming Server/Cloud instance and pull all related SourceItems into the library.
playSource(sourceItem: ISourceItem)-voidThis method will start a playback of a provided Stream Source Item.
getCurrentSourceItem()ISourceItem object or null.ISourceItem | nullReturns current source item. If no source was selected yet, null might be returned instead.
addSourceItem(sourceItem: SourceItem, addAndPlay: boolean)-voidAdd new stream object to the library. It can also start playing it automatically.
enterFullScreen()-voidEnters the FullScreen mode.
exitFullScreen()-voidExits the FullScreen mode.
isFullScreenMode()true if the library is in FullScreen mode.voidReturns true/false whenever a library instance is in the FullScreen mode.
getAbsoluteStreamTime()UnixtimenumberReturns current playback time.
getVideoElement()Reference to the main Video Element.HTMLVideoElementReturns Video Element used by this library instance.
Table 1. Methods table
On this page

API Methods