Classes

Classes

NanoPlayer

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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
activeVideoElement HTMLVideoElement

The current active video element.
IMPORTANT: Video elements should be treated as read-only and not be altered via properties or method calls.

videoElementList Array.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.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object (empty).

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
code NanoPlayer~errorcode

The error code.

message string

The error cause as human readable string.

state NanoPlayer~state

The player state.

See:
Example
// player instance of NanoPlayer
var onError = function (event) {
    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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
entered boolean

Indicates if the player has entered fullscreen mode.

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
connectDelay number

The time in milliseconds to wait for initializing the connection to the server to get the stream. Is zero if no reconnect is imminent.

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
handlerName string

The name of the metadata handler.

message *

The metadata message.

streamTime number

The timestamp of the metadata in relation to currentTime.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
volume number

The current volume in a range from 0.0 to 1.0.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
reason NanoPlayer~pausereason

The reason of pausing.

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
stats object

The startup stats object.

Properties
Name Type Description
connecting number

The time when 'player.play()' is just called in ms (always zero).

connected number

The time when the connection is established in ms (relative to 'connecting').

firstFragmentReceived number

The time when the first fragment is received in ms (relative to 'connecting').

firstFrameRendered number

The time when the first frame is rendered in ms (relative to 'connecting').

playable number

The time when the buffer has enough data to start in ms (relative to 'connecting').

playing number

The time when the playback is started in ms (relative to 'connecting'). It's the total startup time.

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
config config

The config object.

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
serverInfo object

The server info object.

Properties
Name Type Description
applicationServerName string

The application name of the h5live server.

applicationServerVersion object

The application version of the h5live server.

hostname string

The hostname of the h5live server.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object (empty).

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
stats object

The stats object.

Properties
Name Type Description
currentTime number

The current time of the video.

playout object

The playout object.

Properties
Name Type Description
start number

The start play time of the video.

end number

The end play time of the video.

buffer object

The buffer object.

Properties
Name Type Description
start number

The start buffer time of the video.

end number

The end buffer time of the video.

delay object

The delay buffer object.

Properties
Name Type Description
current number

The current delay time.

avg number

The average delay time over the last second.

min number

The minimum delay time over the last second.

max number

The maximum delay time over the last second.

bitrate object

The bitrate object.

Properties
Name Type Description
current number

The current bitrate in Bit/s. Is '0' if not available. NOT AVAILABLE FOR IOS.

avg number

The average bitrate in Bit/s over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.

min number

The minimum bitrate in Bit/s over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.

max number

The maximum bitrate in Bit/s over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.

framerate object

The framerate object.

Properties
Name Type Description
current number

The current network framerate. Is '0' if not available. NOT AVAILABLE FOR IOS.

avg number

The average network framerate over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.

min number

The minimum network framerate over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.

max number

The maximum network framerate over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.

playbackrate object

The playbackrate object. (since 4.14.1)

Properties
Name Type Description
current number

The current video playbackrate. (since 4.14.1)

avg number

The average video playbackrate over the last 10 seconds. (since 4.14.1)

min number

The minimum video playbackrate over the last 10 seconds. (since 4.14.1)

max number

The maximum video playbackrate over the last 10 seconds. (since 4.14.1)

buffergoal object

The buffergoal object. Values used by the latency control (since 4.14.1)

Properties
Name Type Description
base number

The suggested calculated buffergoal value depending on the latency control mode and playback conditions (since 4.14.1)

real number

The final calculated buffergoal value including offsets (since 4.14.1)

min number

The minimum possible buffergoal value. (since 4.14.1)

max number

The maximum possible buffergoal value. (since 4.14.1)

quality object

The video playback quality object.

Properties
Name Type Description
corruptedVideoFrames number

The total number of corrupted video frames.

corruptedVideoFramesCurrent number

The number of corrupted video frames within the last second.

creationTime number

The time in miliseconds since the start of the navigation and the creation of the video element.

droppedVideoFrames number

The total number of dropped video frames.

droppedVideoFramesCurrent number

The number of dropped video frames within the last second.

totalVideoFrames number

The total number of created and dropped video frames since creation of the video element.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object (empty).

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
streamInfo object

The stream info object.

Properties
Name Type Description
url string

The complete stream url with parameters.

rtmp object

The rtmp stream object.

rtmo.url string

The rtmp stream url.

rtmp.streamname string

The rtmp streamname.

haveAudio boolean

Indicates if the stream contains audio.

haveVideo boolean

Indicates if the stream contains video.

audioInfo object | null

The audio info object. Is 'null' if the stream contains no audio.

Properties
Name Type Description
bitsPerSample number | null

The bits per sample. Is 'null' if not available. NOT AVAILABLE FOR IOS.

sampleRate number | null

The audio sample rate. Is 'null' if not available. NOT AVAILABLE FOR IOS.

channels number | null

The number of audio channels. Is 'null' if not available. NOT AVAILABLE FOR IOS.

videoInfo object | null

The stream info object. Is 'null' if the stream contains no video.

Properties
Name Type Description
width number | null

The width of the video. Is 'null' if not available.

height number | null

The height of the video. Is 'null' if not available.

frameRate number | null

The video frame rate. Is 'null' if not available. NOT AVAILABLE FOR IOS.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
streamInfo object

The stream info object.

Properties
Name Type Description
url string

The complete stream url with parameters.

haveAudio boolean

Indicates if the stream contains audio.

haveVideo boolean

Indicates if the stream contains video.

audioInfo object | null

The audio info object. Is 'null' if the stream contains no audio.

Properties
Name Type Description
bitsPerSample number | null

The bits per sample. Is 'null' if not available. NOT AVAILABLE FOR IOS.

sampleRate number | null

The audio sample rate. Is 'null' if not available. NOT AVAILABLE FOR IOS.

channels number | null

The number of audio channels. Is 'null' if not available. NOT AVAILABLE FOR IOS.

videoInfo object | null

The stream info object. Is 'null' if the stream contains no video.

Properties
Name Type Description
width number | null

The width of the video. Is 'null' if not available.

height number | null

The height of the video. Is 'null' if not available.

frameRate number | null

The video frame rate. Is 'null' if not available. NOT AVAILABLE FOR IOS.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
source object

The current source object.

entry object

The current source entry.

rule string

The adaption switch rule.

reason string

The abort reason. Possible values are 'equalsource', 'superseded' and 'frequency'.

tag string

A static string in format: {data.entry.h5live.rtmp.streamname} + ' streamSwitch ' + {data.id}.

count number

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'

type string

The switch type. Possible values are 'up', 'down' (in case of adaptive stream switch) and 'direct' (switch via 'switchStream').

id number

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'

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data.source object

The current source object.

data.entry object

The current source entry.

data.rule string

The adaption switch rule.

data.code object

The error code. Similar to the errorcodes.

data.message object

The error message.

data.tag string

A static string in format: {data.entry.h5live.rtmp.streamname} + ' streamSwitch ' + {data.id}.

data.count number

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.type string

The switch type. Possible values are 'up', 'down' (in case of adaptive stream switch) and 'direct' (switch via 'switchStream').

data.id number

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'

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
source object

The current source object.

entry object

The current source entry.

rule string

The adaption switch rule.

options object

The switch options object.

tag string

A static string in format: {data.entry.h5live.rtmp.streamname} + ' streamSwitch ' + {data.id}.

count number

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'

type string

The switch type. Possible values are 'up', 'down' (in case of adaptive stream switch) and 'direct' (switch via 'switchStream').

id number

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'

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
source object

The current source object.

entry object

The current source entry.

rule string

The adaption switch rule.

tag string

A static string in format: {data.entry.h5live.rtmp.streamname} + ' streamSwitch ' + {data.id}.

count number

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'

type string

The switch type. Possible values are 'up', 'down' (in case of adaptive stream switch) and 'direct' (switch via 'switchStream').

id number

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'

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
volume number

The current volume in a range from 0.0 to 1.0.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
source object

The current source object.

entry object

The current source entry.

rule string

The adaption switch rule.

reason string

The abort reason. Possible values are 'equalsource', 'superseded' and 'frequency'.

tag string

The custom tag string given in the options object of the 'updateSource' call. Is an empty string if not set.

count number

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'

type string

The switch type. Here always 'update'.

id number

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'

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data.source object

The current source object.

data.entry object

The current source entry.

data.rule string

The adaption switch rule.

data.code object

The error code. Similar to the errorcodes.

data.message object

The error message.

data.tag string

The custom tag string given in the options object of the 'updateSource' call. Is an empty string if not set.

data.count number

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.type string

The switch type. Here always 'update'.

data.id number

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'

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
source object

The current source object.

entry object

The current source entry.

rule string

The adaption switch rule.

options object

The switch options object.

tag string

The custom tag string given in the options object of the 'updateSource' call. Is an empty string if not set.

count number

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'

type string

The switch type. Here always 'update'.

id number

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'

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
source object

The current source object.

entry object

The current source entry.

rule string

The adaption switch rule.

tag string

The custom tag string given in the options object of the 'updateSource' call. Is an empty string if not set.

count number

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'

type string

The switch type. Here always 'update'.

id number

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'

state NanoPlayer~state

The player state.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
volume number

The current volume in a range from 0.0 to 1.0.

See:
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
Properties:
Name Type Description
name string

The event name.

player string

The player name (id of the playerDiv).

id string

The unique id of the player instance.

version string

The version of the player.

data object

The data object.

Properties
Name Type Description
message string

The warning as human readable string.

state NanoPlayer~state

The player state.

See:
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);
});