Classes

Classes

NanoPlayer

Events


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

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

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.

quality object

The video playback quality object.

Properties
Name Type Description
corruptedVideoFrames number

The total number of corrupted video frames. ONLY AVAILABLE FOR FIREFOX.

corruptedVideoFramesCurrent number

The number of corrupted video frames within the last second. ONLY AVAILABLE FOR FIREFOX.

creationTime number

The time in miliseconds since the start of the navigation and the creation of the video element. ONLY AVAILABLE FOR FIREFOX.

droppedVideoFrames number

The total number of dropped video frames. ONLY AVAILABLE FOR FIREFOX.

droppedVideoFramesCurrent number

The number of dropped video frames within the last second. ONLY AVAILABLE FOR FIREFOX.

totalVideoFrames number

The total number of created and dropped video frames since creation of the video element. ONLY AVAILABLE FOR FIREFOX.

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.

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

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 ('updatefrequency'). 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
reason string

The options object used for the 'updateSource' call. Possible values are 'equalsource', 'superseded' and 'updatefrequency'.

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'

state NanoPlayer~state

The player state.

See:
Example
// player instance of NanoPlayer
var onUpdateSourceAbort = function (event) {
    console.log('Update Source Abort with source: ' + JSON.stringify(event.data.source) + ' and options: ' + JSON.stringify(event.data.options));
    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 object

The data object.

Properties
Name Type Description
code object

The error code. Similar to the errorcodes.

message object

The error message.

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'

state NanoPlayer~state

The player state.

See:
Example
// player instance of NanoPlayer
var onUpdateSourceFail = function (event) {
    console.log('Update Source Fail 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 source object given in the 'updateSource' call.

options object

The options object used for the 'updateSource' call.

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'

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
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'

state NanoPlayer~state

The player state.

See:
Example
// player instance of NanoPlayer
var onUpdateSourceSuccess = function (event) {
    console.log('Update Source Success 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);
});