Classes
Events
-
onActiveVideoElementChange
-
The event that fires when the active video element for playback has been created and if the element has been changed in case of a stream switch on iOS (HLS playback on iOS requires two video elements for a smooth stream switch behaviour).
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description activeVideoElementHTMLVideoElement The current active video element.
IMPORTANT: Video elements should be treated as read-only and not be altered via properties or method calls.videoElementListArray.HTMLVideoElement The list of available video elements. Has two elements in case of iOS playback.
IMPORTANT: Video elements should be treated as read-only and not be altered via properties or method calls.Example
// player instance of NanoPlayer var onActiveVideoElementChange = function (event) { var activeVideoElement = event.data.activeVideoElement; var videoElementList = event.data.videoElementList; // IMPORTANT: Video elements should be treated as read-only and not be altered via properties or method calls. if (activeVideoElement) { console.log('ActiveVideoElementChange: The current active video element has the id: \'' + activeVideoElement.id + '\''); } for (var i = 0; i < videoElementList.length; i += 1) { console.log('ActiveVideoElementChange: The video element at index ' + i + ' has the id \'' + videoElementList[i].id + '\''); } }; config.events.onActiveVideoElementChange = onActiveVideoElementChange; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onDestroy
-
The destroy event to pass in the 'config.events' object at the setup call. Fires if the player is destroyed.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object (empty).
stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onDestroy = function (event) { console.log('player destroy'); }; config.events.onDestroy = onDestroy; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onError
-
The error event to pass in the 'config.events' object at the setup call. Fires if any kind of error occures.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Argument Description codeNanoPlayer~errorcode The error code.
messagestring The error cause as human readable string.
playbackobject <optional>
The optional data playback object (since 4.28.0). Includes current playback stats. Only available if error is a startup error.
Properties
Name Type Description bufferDelayCurrentnumber Buffer delay in ms experienced at the time of the error. Always available.
bitrateCurrentnumber The bitrate in Bit/s of playback at the time the error occurred. Always available.
framerateCurrentnumber Playback framerate per second at the time of the error. Always available.
stateobject <optional>
The optional data state object (since 4.28.0). Includes all timestamps of the startup phase that have been reached before the error occurred. Only available if error is a startup error.
Properties
Name Type Argument Description connectednumber <optional>
Timestamp in ms indicating when the connection was established (relative to load start). Optional.
firstFragmentReceivednumber <optional>
Time in ms at which the first fragment of media data was received (relative to load start). Optional.
firstFrameRenderednumber <optional>
Time in ms when the first frame was rendered (relative to load start). Optional.
playablenumber <optional>
Timestamp in ms indicating when playback was ready to begin (relative to load start). Optional.
playingnumber <optional>
Timestamp in ms indicating when playback actually started (relative to load start). Optional.
errornumber Timestamp in ms marking when the error occurred (relative to load start). Always available.
stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onError = function (event) { if (event.data.state) { alert('Startup Error: ' + event.data.code + ' ' + event.data.message + ' at ' + event.data.state.error + 'ms after load start'); } else { alert('Error: ' + event.data.code + ' ' + event.data.message); } }; config.events.onError = onError; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onFullscreenChange
-
The fullscreen change event to pass in the 'config.events' object at the setup call. Fires if the fullscreen mode of the player has changed.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description enteredboolean Indicates if the player has entered fullscreen mode.
stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onFullscreenChange = function (event) { console.log('FullscreenChange'); if (event.data.entered === true) { console.log('Fullscreen Mode Entered'); } }; config.events.onFullscreenChange = onFullscreenChange; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onLoading
-
The load event to pass in the 'config.events' object at the setup call. Fires if playout was stopped or player is ready after setup and tries to play.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description connectDelaynumber The time in milliseconds to wait for initializing the connection to the server to get the stream. Is zero if no reconnect is imminent.
stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onLoading = function (event) { console.log('Loading with delay of ' + event.data.connectDelay + ' milliseconds'); }; config.events.onLoading = onLoading; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onMetaData
-
The metadata event to pass in the 'config.events' object at the setup call. The config param 'playback.metadata' have to be set to true. Fires if the player receives metadata.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description handlerNamestring The name of the metadata handler.
message* The metadata message.
streamTimenumber The timestamp of the metadata in relation to currentTime.
Example
// player instance of NanoPlayer var onMetaData = function (event) { console.log('MetaData: ' + JSON.stringify(event.data)); }; config.events.onMetaData = onMetaData; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onMute
-
The mute event to pass in the 'config.events' object at the setup call. Fires if the player is muted.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description volumenumber The current volume in a range from 0.0 to 1.0.
Example
// player instance of NanoPlayer var onMute = function (event) { console.log('Muted with volume: ' + event.data.volume); }; config.events.onMute = onMute; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onPause
-
The pause event to pass in the 'config.events' object at the setup call. Fires if playout is paused.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description reasonNanoPlayer~pausereason The reason of pausing.
stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onPause = function (event) { console.log('Pause'); if (event.data.reason !== 'normal') { alert('Paused with reason: ' + event.data.reason); } }; config.events.onPause = onPause; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onPlay
-
The play event to pass in the 'config.events' object at the setup call. Fires if playout is started.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description statsobject The startup stats object.
Properties
Name Type Description connectingnumber The time when 'player.play()' is just called in ms (always zero).
connectednumber The time when the connection is established in ms (relative to 'connecting').
firstFragmentReceivednumber The time when the first fragment is received in ms (relative to 'connecting').
firstFrameRenderednumber The time when the first frame is rendered in ms (relative to 'connecting').
playablenumber The time when the buffer has enough data to start in ms (relative to 'connecting').
playingnumber The time when the playback is started in ms (relative to 'connecting'). It's the total startup time.
stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onPlay = function (event) { console.log('Playing'); console.log('play stats: ' + JSON.stringify(event.data.stats)); }; config.events.onPlay = onPlay; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onReady
-
The ready event to pass in the 'config.events' object at the setup call. Fires if the player is ready to play after successful setup.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description configconfig The config object.
stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onReady = function (event) { console.log('Ready: ' + JSON.stringify(event.data.config)); } config.events.onReady = onReady; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onServerInfo
-
The server info event to pass in the 'config.events' object at the setup call. Fires if informations about the connected h5live server is available.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description serverInfoobject The server info object.
Properties
Name Type Description applicationServerNamestring The application name of the h5live server.
applicationServerVersionobject The application version of the h5live server.
hostnamestring The hostname of the h5live server.
Example
// player instance of NanoPlayer var onServerInfo = function (event) { console.log('ServerInfo: ' + JSON.stringify(event.data.serverInfo)); }; config.events.onServerInfo = onServerInfo; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onStartBuffering
-
The start buffering event to pass in the 'config.events' object at the setup call. Fires if playout is started but no media is available.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object (empty).
stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onStartBuffering = function (event) { console.log('Buffering'); }; config.events.onStartBuffering = onStartBuffering; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onStats
-
The stats event to pass in the 'config.events' object at the setup call. Fires if the player has measured statistics.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description statsobject The stats object.
Properties
Name Type Description currentTimenumber The current time of the video.
playoutobject The playout object.
Properties
Name Type Description startnumber The start play time of the video.
endnumber The end play time of the video.
bufferobject The buffer object.
Properties
Name Type Description startnumber The start buffer time of the video.
endnumber The end buffer time of the video.
delayobject The delay buffer object.
Properties
Name Type Description currentnumber The current delay time.
avgnumber The average delay time over the last second.
minnumber The minimum delay time over the last second.
maxnumber The maximum delay time over the last second.
bitrateobject The bitrate object.
Properties
Name Type Description currentnumber The current bitrate in Bit/s. Is '0' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
avgnumber The average bitrate in Bit/s over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
minnumber The minimum bitrate in Bit/s over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
maxnumber The maximum bitrate in Bit/s over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
framerateobject The framerate object.
Properties
Name Type Description currentnumber The current network framerate. Is '0' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
avgnumber The average network framerate over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
minnumber The minimum network framerate over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
maxnumber The maximum network framerate over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
playbackrateobject The playbackrate object. (since 4.14.1)
Properties
Name Type Description currentnumber The current video playbackrate. (since 4.14.1)
avgnumber The average video playbackrate over the last 10 seconds. (since 4.14.1)
minnumber The minimum video playbackrate over the last 10 seconds. (since 4.14.1)
maxnumber The maximum video playbackrate over the last 10 seconds. (since 4.14.1)
buffergoalobject The buffergoal object. Values used by the latency control (since 4.14.1)
Properties
Name Type Description basenumber The suggested calculated buffergoal value depending on the latency control mode and playback conditions (since 4.14.1)
realnumber The final calculated buffergoal value including offsets (since 4.14.1)
minnumber The minimum possible buffergoal value. (since 4.14.1)
maxnumber The maximum possible buffergoal value. (since 4.14.1)
qualityobject The video playback quality object.
Properties
Name Type Description corruptedVideoFramesnumber The total number of corrupted video frames.
corruptedVideoFramesCurrentnumber The number of corrupted video frames within the last second.
creationTimenumber The time in miliseconds since the start of the navigation and the creation of the video element.
droppedVideoFramesnumber The total number of dropped video frames.
droppedVideoFramesCurrentnumber The number of dropped video frames within the last second.
totalVideoFramesnumber The total number of created and dropped video frames since creation of the video element.
Example
// player instance of NanoPlayer var onStats = function (event) { console.log('Stats: ' + JSON.stringify(event.data.stats)); }; config.events.onStats = onStats; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onStopBuffering
-
The stop buffering event to pass in the 'config.events' object at the setup call. Fires if playout resumes after buffering.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object (empty).
stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onStopBuffering = function (event) { console.log('Resume'); }; config.events.onStopBuffering = onStopBuffering; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onStreamInfo
-
The stream info event to pass in the 'config.events' object at the setup call. Fires if informations about a stream is available right before playback starts.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description streamInfoobject The stream info object.
Properties
Name Type Description urlstring The complete stream url with parameters.
rtmpobject The rtmp stream object.
rtmo.urlstring The rtmp stream url.
rtmp.streamnamestring The rtmp streamname.
haveAudioboolean Indicates if the stream contains audio.
haveVideoboolean Indicates if the stream contains video.
audioInfoobject | null The audio info object. Is 'null' if the stream contains no audio.
Properties
Name Type Description bitsPerSamplenumber | null The bits per sample. Is 'null' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
sampleRatenumber | null The audio sample rate. Is 'null' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
channelsnumber | null The number of audio channels. Is 'null' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
videoInfoobject | null The stream info object. Is 'null' if the stream contains no video.
Properties
Name Type Description widthnumber | null The width of the video. Is 'null' if not available.
heightnumber | null The height of the video. Is 'null' if not available.
frameRatenumber | null The video frame rate. Is 'null' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
Example
// player instance of NanoPlayer var onStreamInfo = function (event) { console.log('StreamInfo: ' + JSON.stringify(event.data.streamInfo)); }; config.events.onStreamInfo = onStreamInfo; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onStreamInfoUpdate
-
The stream info event to pass in the 'config.events' object at the setup call. Fires if the stream format has changed during playback.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description streamInfoobject The stream info object.
Properties
Name Type Description urlstring The complete stream url with parameters.
haveAudioboolean Indicates if the stream contains audio.
haveVideoboolean Indicates if the stream contains video.
audioInfoobject | null The audio info object. Is 'null' if the stream contains no audio.
Properties
Name Type Description bitsPerSamplenumber | null The bits per sample. Is 'null' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
sampleRatenumber | null The audio sample rate. Is 'null' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
channelsnumber | null The number of audio channels. Is 'null' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
videoInfoobject | null The stream info object. Is 'null' if the stream contains no video.
Properties
Name Type Description widthnumber | null The width of the video. Is 'null' if not available.
heightnumber | null The height of the video. Is 'null' if not available.
frameRatenumber | null The video frame rate. Is 'null' if not available. NOT AVAILABLE FOR HLS PLAYBACK.
Example
// player instance of NanoPlayer var onStreamInfoUpdate = function (event) { console.log('StreamInfo updated: ' + JSON.stringify(event.data.streamInfo)); }; config.events.onStreamInfoUpdate = onStreamInfoUpdate; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onSwitchStreamAbort
-
The event to signal that the switch stream request is aborted. Reasons can be an equal source ('equalsource'), a superseding ('superseded') or an to less time range between two 'switchStream' calls ('frequency'). This is an completion event that follows on an start event.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description sourceobject The current source object.
entryobject The current source entry.
rulestring The adaption switch rule.
reasonstring The abort reason. Possible values are 'equalsource', 'superseded' and 'frequency'.
tagstring A static string in format: {data.entry.h5live.rtmp.streamname} + ' streamSwitch ' + {data.id}.
countnumber The count of the switch stream request to identify the paired start and completion event. The start event is
'onSwitchStreamInit'and completion events are'onSwitchStreamSuccess','onSwitchStreamFail'and'onSwitchStreamAbort'typestring The switch type. Possible values are 'up', 'down' (in case of adaptive stream switch) and 'direct' (switch via
'switchStream').idnumber The id of the switch stream request to identify the paired start and completion event. The start event is
'onSwitchStreamInit'and completion events are'onSwitchStreamSuccess','onSwitchStreamFail'and'onSwitchStreamAbort'stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onSwitchStreamAbort = function (event) { console.log('switch stream abort by rule ' + event.data.rule + ' from type ' + event.data.type + 'with entry: ' + JSON.stringify(event.data.entry) + ' with reason: ' + event.data.reason)); console.log('tag: ' + event.data.tag); console.log('count: ' + event.data.count); }; config.events.onSwitchStreamAbort = onSwitchStreamAbort; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onSwitchStreamFail
-
The event to signal that the switch stream request is failed. Fired if an error occure during the update. This is an completion event that follows on an start event.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
data.sourceobject The current source object.
data.entryobject The current source entry.
data.rulestring The adaption switch rule.
data.codeobject The error code. Similar to the
errorcodes.data.messageobject The error message.
data.tagstring A static string in format: {data.entry.h5live.rtmp.streamname} + ' streamSwitch ' + {data.id}.
data.countnumber The count of the switch stream request to identify the paired start and completion event. The start event is
'onSwitchStreamInit'and completion events are'onSwitchStreamSuccess','onSwitchStreamFail'and'onSwitchStreamAbort'data.typestring The switch type. Possible values are 'up', 'down' (in case of adaptive stream switch) and 'direct' (switch via
'switchStream').data.idnumber The id of the switch stream request to identify the paired start and completion event. The start event is
'onSwitchStreamInit'and completion events are'onSwitchStreamSuccess','onSwitchStreamFail'and'onSwitchStreamAbort'stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onSwitchStreamFail = function (event) { console.log('switch stream fail by rule ' + event.data.rule + ' from type ' + event.data.type + 'with entry: ' + JSON.stringify(event.data.entry) + ' with error code: ' + event.data.code + ' and error message: ' + event.data.message); console.log('switch stream tag: ' + event.data.tag); console.log('switch stream count: ' + event.data.count); }; config.events.onSwitchStreamFail = onSwitchStreamFail; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onSwitchStreamInit
-
The event to signal that an stream switch request is initialized. Can be triggered by an adaptive rule (ABR) request or via
'switchStream'. This is always the start event, an completion event will follow.Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description sourceobject The current source object.
entryobject The current source entry.
rulestring The adaption switch rule.
optionsobject The switch options object.
tagstring A static string in format: {data.entry.h5live.rtmp.streamname} + ' streamSwitch ' + {data.id}.
countnumber The count of the switch stream request to identify the paired start and completion event. The start event is
'onSwitchStreamInit'and completion events are'onSwitchStreamSuccess','onSwitchStreamFail'and'onSwitchStreamAbort'typestring The switch type. Possible values are 'up', 'down' (in case of adaptive stream switch) and 'direct' (switch via
'switchStream').idnumber The id of the switch stream request to identify the paired start and completion event. The start event is
'onSwitchStreamInit'and completion events are'onSwitchStreamSuccess','onSwitchStreamFail'and'onSwitchStreamAbort'stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onSwitchStreamInit = function (event) { console.log('switch stream init by rule ' + event.data.rule + ' from type ' + event.data.type + 'with entry: ' + JSON.stringify(event.data.entry) + ' and options: ' + JSON.stringify(event.data.options)); console.log('switch stream tag: ' + event.data.tag); console.log('switch stream count: ' + event.data.count); }; config.events.onSwitchStreamInit = onSwitchStreamInit; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onSwitchStreamSuccess
-
The event to signal that the switch stream request is succeeded. Fires if the source is updated. This is an completion event that follows on an start event.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description sourceobject The current source object.
entryobject The current source entry.
rulestring The adaption switch rule.
tagstring A static string in format: {data.entry.h5live.rtmp.streamname} + ' streamSwitch ' + {data.id}.
countnumber The count of the switch stream request to identify the paired start and completion event. The start event is
'onSwitchStreamInit'and completion events are'onSwitchStreamSuccess','onSwitchStreamFail'and'onSwitchStreamAbort'typestring The switch type. Possible values are 'up', 'down' (in case of adaptive stream switch) and 'direct' (switch via
'switchStream').idnumber The id of the switch stream request to identify the paired start and completion event. The start event is
'onSwitchStreamInit'and completion events are'onSwitchStreamSuccess','onSwitchStreamFail'and'onSwitchStreamAbort'stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onSwitchStreamSuccess = function (event) { console.log('switch stream success by rule ' + event.data.rule + ' from type ' + event.data.type + 'with entry: ' + JSON.stringify(event.data.entry) + ' with tag: ' + event.data.tag + ' and count: ' + event.data.count); }; config.events.onSwitchStreamSuccess = onSwitchStreamSuccess; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onUnmute
-
The unmute event to pass in the 'config.events' object at the setup call. Fires if the player is unmuted.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description volumenumber The current volume in a range from 0.0 to 1.0.
Example
// player instance of NanoPlayer var onUnmute = function (event) { console.log('Unmuted with volume: ' + event.data.volume); }; config.events.onUnmute = onUnmute; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onUpdateSourceAbort
-
The event to signal that the update source request is aborted. Reasons can be an equal source ('equalsource'), a superseding ('superseded') or an to less time range between two 'updateSource' calls ('frequency'). This is an completion event that follows on an start event.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description sourceobject The current source object.
entryobject The current source entry.
rulestring The adaption switch rule.
reasonstring The abort reason. Possible values are 'equalsource', 'superseded' and 'frequency'.
tagstring The custom tag string given in the options object of the
'updateSource'call. Is an empty string if not set.countnumber The count of the update source request to identify the paired start and completion event. The start event is
'onUpdateSourceInit'and completion events are'onUpdateSourceSuccess','onUpdateSourceFail'and'onUpdateSourceAbort'typestring The switch type. Here always 'update'.
idnumber The id of the update source request to identify the paired start and completion event. The start event is
'onUpdateSourceInit'and completion events are'onUpdateSourceSuccess','onUpdateSourceFail'and'onUpdateSourceAbort'stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onUpdateSourceAbort = function (event) { console.log('update source abort with entry: ' + JSON.stringify(event.data.entry) + ' and reason: ' + event.data.reason); console.log('tag: ' + event.data.tag); console.log('count: ' + event.data.count); }; config.events.onUpdateSourceAbort = onUpdateSourceAbort; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onUpdateSourceFail
-
The event to signal that the update source request is failed. Fired if an error occure during the update. This is an completion event that follows on an start event.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
data.sourceobject The current source object.
data.entryobject The current source entry.
data.rulestring The adaption switch rule.
data.codeobject The error code. Similar to the
errorcodes.data.messageobject The error message.
data.tagstring The custom tag string given in the options object of the
'updateSource'call. Is an empty string if not set.data.countnumber The count of the update source request to identify the paired start and completion event. The start event is
'onUpdateSourceInit'and completion events are'onUpdateSourceSuccess','onUpdateSourceFail'and'onUpdateSourceAbort'data.typestring The switch type. Here always 'update'.
data.idnumber The id of the update source request to identify the paired start and completion event. The start event is
'onUpdateSourceInit'and completion events are'onUpdateSourceSuccess','onUpdateSourceFail'and'onUpdateSourceAbort'stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onUpdateSourceFail = function (event) { console.log('update source fail with entry: ' + JSON.stringify(event.data.entry) + ', with error code: ' + event.data.code + ' and error message: ' + event.data.message); console.log('update source tag: ' + event.data.tag); console.log('update source count: ' + event.data.count); }; config.events.onUpdateSourceFail = onUpdateSourceFail; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onUpdateSourceInit
-
The event to signal that the update source request is initialized. This is always the start event, an completion event will follow.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description sourceobject The current source object.
entryobject The current source entry.
rulestring The adaption switch rule.
optionsobject The switch options object.
tagstring The custom tag string given in the options object of the
'updateSource'call. Is an empty string if not set.countnumber The count of the update source request to identify the paired start and completion event. The start event is
'onUpdateSourceInit'and completion events are'onUpdateSourceSuccess','onUpdateSourceFail'and'onUpdateSourceAbort'typestring The switch type. Here always 'update'.
idnumber The id of the update source request to identify the paired start and completion event. The start event is
'onUpdateSourceInit'and completion events are'onUpdateSourceSuccess','onUpdateSourceFail'and'onUpdateSourceAbort'stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onUpdateSourceInit = function (event) { console.log('update source init with source: ' + JSON.stringify(event.data.source) + ' and options: ' + JSON.stringify(event.data.options)); console.log('update source tag: ' + event.data.tag); console.log('update source count: ' + event.data.count); }; config.events.onUpdateSourceInit = onUpdateSourceInit; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onUpdateSourceSuccess
-
The event to signal that the update source request is succeeded. Fires if the source is updated. This is an completion event that follows on an start event.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description sourceobject The current source object.
entryobject The current source entry.
rulestring The adaption switch rule.
tagstring The custom tag string given in the options object of the
'updateSource'call. Is an empty string if not set.countnumber The count of the update source request to identify the paired start and completion event. The start event is
'onUpdateSourceInit'and completion events are'onUpdateSourceSuccess','onUpdateSourceFail'and'onUpdateSourceAbort'typestring The switch type. Here always 'update'.
idnumber The id of the update source request to identify the paired start and completion event. The start event is
'onUpdateSourceInit'and completion events are'onUpdateSourceSuccess','onUpdateSourceFail'and'onUpdateSourceAbort'stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onUpdateSourceSuccess = function (event) { console.log('update source success with entry: ' + JSON.stringify(event.data.entry) + ', with tag: ' + event.data.tag + ' and count: ' + event.data.count); }; config.events.onUpdateSourceSuccess = onUpdateSourceSuccess; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onVolumeChange
-
The volume change event to pass in the 'config.events' object at the setup call. Fires if the player's volume has changed.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description volumenumber The current volume in a range from 0.0 to 1.0.
Example
// player instance of NanoPlayer var onVolumeChange = function (event) { console.log('Volume: ' + event.data.volume); }; config.events.onVolumeChange = onVolumeChange; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
onWarning
-
The error event to pass in the 'config.events' object at the setup call. Fires if something is not as expected, but functionality works.
Type: object
- See:
Properties:
Name Type Description namestring The event name.
playerstring The player name (id of the playerDiv).
idstring The unique id of the player instance.
versionstring The version of the player.
dataobject The data object.
Properties
Name Type Description messagestring The warning as human readable string.
stateNanoPlayer~state The player state.
Example
// player instance of NanoPlayer var onWarning = function (event) { console.log('Warning: ' + event.data.message); }; config.events.onWarning = onWarning; player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); });