new NanoPlayer(playerDivId)
The constructor. The source can be loaded via script tag, AMD (requirejs) or CommonJS
Parameters:
| Name | Type | Description |
|---|---|---|
playerDivId |
string | The div element the player will be embedded into. |
- Version:
-
- 5.0.2
Examples
<!-- Example: load player with new video element into playerDiv -->
<div id="playerDiv"></div>
<script type="text/javascript" src="nanoplayer.5.min.js"></script>
<script type="text/javascript">
var player;
var config = {
"source": {
"entries": [
{
"h5live": {
// your rtmp stream
"rtmp": {
"url": "rtmp://bintu-play.nanocosmos.de/play",
"streamname": "XXXXX-YYYYY"
},
"server": {
"websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4",
"hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8",
"progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4"
}
}
}
]
}
};
function initPlayer() {
player = new NanoPlayer('playerDiv');
player.setup(config).then(function (config) {
console.log('setup ok with config: ' + JSON.stringify(config));
}, function (error) {
console.log(error);
});
}
// load player from playerDiv
document.addEventListener('DOMContentLoaded', function () {
initPlayer();
});
</script>
<!-- Example: load player with existing html video element -->
<div id="playerDiv">
<video id="myPlayer"></video>
<!-- HLS PLAYBACK ONLY uses 2 video elements for playback if more than one stream is configured, required for seamless stream switching -->
<video id="myPlayer2"></video>
</div>
<script>
var player;
var config = {
"source": {
"entries": [
{
"h5live": {
// your rtmp stream
"rtmp": {
"url": "rtmp://bintu-play.nanocosmos.de/play",
"streamname": "XXXXX-YYYYY"
},
"server": {
"websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4",
"hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8",
"progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4"
}
}
}
]
},
"playback": {
"videoId": ["myPlayer", "myPlayer2"]
}
};
function initPlayer() {
player = new NanoPlayer('playerDiv');
player.setup(config).then(function (config) {
console.log('setup ok with config: ' + JSON.stringify(config));
}, function (error) {
console.log(error);
});
}
document.addEventListener('DOMContentLoaded', function () {
initPlayer();
});
</script>
<!-- Example: load player with require.js -->
<script type="text/javascript" src="require.js"></script>
<script type="text/javascript">
var player;
requirejs.config({
paths: {
// loads the player ...
// for a local copy of the minified player use a relative path e.g. 'js/nanoplayer.5.min'
// if 'baseUrl' is defined a local path have to be relative to the base path
nanoplayer: '//demo.nanocosmos.de/nanoplayer/api/release/nanoplayer.5.min.js'
},
waitSeconds: 20, // timeout for loading modules
});
require('nanoplayer', function() {
initPlayer();
});
</script>
Members
-
<constant> capabilities :Array.<string>
-
The supported tech names of the player.
Type:
- Array.<string>
-
coreversion :string
-
The version of the core.
Type:
- string
-
id :string
-
The unique id of the player.
Type:
- string
-
tech :string
-
The playback technology of the player.
Type:
- string
-
type :string
-
The type of the player.
Type:
- string
-
version :string
-
The version of the player.
Type:
- string
-
viewversion :string
-
The version of the view.
Type:
- string
Methods
-
destroy()
-
Cleans up the player and removes all nested elements from the container div.
Example
// player instance of NanoPlayer player.destroy(); player.setup(config);
-
exitFullscreen() → {Promise.<(undefined|error)>}
-
Exit fullscreen mode if entered.
Returns:
- Type
- Promise.<(undefined|error)>
Example
// player instance of NanoPlayer player.exitFullscreen() .then(function (){ console.log('exitFullscreen resolved'); }) .catch(function(err) { // error reasons can be 'denied' or 'disabled' (e.g. in audio player mode) console.log('exitFullscreen rejected: ' + err.reason); }); -
mute()
-
Mutes the player.
Example
// player instance of NanoPlayer player.mute();
-
pause()
-
Pauses the player.
Example
// player instance of NanoPlayer player.pause();
-
play()
-
Plays the player.
Example
// player instance of NanoPlayer player.play();
-
requestFullscreen() → {Promise.<(undefined|error)>}
-
Request fullscreen mode for the player if not entered.
Returns:
- Type
- Promise.<(undefined|error)>
Example
// player instance of NanoPlayer player.requestFullscreen() .then(function (){ console.log('requestFullscreen resolved'); }) .catch(function(err) { // error reasons can be 'denied' or 'disabled' (e.g. in audio player mode) console.log('requestFullscreen rejected: ' + err.reason); }); -
setAdaption(adaption)
-
Set a desired adaption rule or disable adaption on the fly.
Parameters:
Name Type Description adaptionobject The adaption object similar than the object 'config.source.options.adaption'.
- See:
Example
// player instance of NanoPlayer var adaption = { "rule": "deviationOfMean2", "downStep": 2, "omitRenditions": ["high", "low"] } if (!useAdaption) { adaption.rule = "none"; } player.setAdaption(adaption); -
setup(config) → {Promise.<(config|error)>}
-
Initializes the player with a given config object.
Parameters:
Name Type Description configNanoPlayer~config The config object for the player including sources, events, styles.
- See:
Returns:
- Type
- Promise.<(config|error)>
Example
// player instance of NanoPlayer player.setup(config).then(function (config) { console.log('setup ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
setVolume(volume)
-
Sets the volume of the player. NOT AVAILABLE FOR HLS PLAYBACK, see here for more informations.
Parameters:
Name Type Description volumenumber The volume to set in a range from 0.0 to 1.0.
Example
// player instance of NanoPlayer player.setVolume(0.3);
-
switchStream(index) → {Promise.<(config|error)>}
-
Switch to a stream given over source entries.
Parameters:
Name Type Description indexnumber The index of the stream in the given stream set to switch to.
- See:
Returns:
- Type
- Promise.<(config|error)>
Example
// player instance of NanoPlayer player.switchStream(1).then(function (config) { console.log('switch stream initialized with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); }); -
unmute()
-
Unmutes the player.
Example
// player instance of NanoPlayer player.unmute();
-
updateSource(source) → {Promise.<(config|error)>}
-
Updates the source of the player.
Parameters:
Name Type Description sourceobject The object to configure the source to play, one of the following properties have to be set.
Properties
Name Type Argument Default Description entriesArray.<NanoPlayer~entry> <optional>
The source entries array for a set of streams. USE INSTEAD OF SOURCE.H5LIVE. Used to configure stream entries. Can have one to many 'entry' objects. Only one existing entry is similar than a single source. In this case no entries options are needed.
startIndexnumber <optional>
0 The index of the entry to start playback with. Can be in the range from 0 to 'entries.length-1'.
optionsobject <optional>
The object to configure the source entries options.
Properties
Name Type Argument Description switchobject <optional>
The object to configure the stream switch options like method etc.
Properties
Name Type Argument Default Description methodstring <optional>
server The update method. Possible values are 'server' (default) and 'client'.
pauseOnErrorboolean <optional>
false If set the player stops if an error occure during the stream switch. Default is false.
forcePlayboolean <optional>
true If set the player starts playback in case the player is paused. Default is true.
fastStartboolean <optional>
true Only if method is 'server'. Tries to accelerate the startup time of the new source. Default is true.
timeoutnumber <optional>
20 The timeout for the update source request in seconds. If reached the error 4006 will thrown in the
'onUpdateSourceFail'event. Default is 10 seconds, valid range is between 5 and 30.tagstring <optional>
A custom field that can be any string like 'stream-800k' or '720p'. This tag will be returned in any completion event of the 'updateSource' request like 'onUpdateSourceSuccess', 'onUpdateSourceFail' and 'onUpdateSourceAbort'.
adaptionobject <optional>
The object to set an adaption for switching.
Properties
Name Type Argument Default Description rulestring <optional>
none The switch rule if multiple entries are defined. Possible values are 'deviationOfMean' (ABR automatic), 'deviationOfMean2' (ABR automatic) and 'none' (default, means only manual stream switch via 'switchStream' possible).
downStepnumber <optional>
1 The minimum number of steps during a ABR down switch ('deviationOfMean' and 'deviationOfMean2' only).
h5liveobject <optional>
DEPRECATED. PLEASE USE ENTRIES!!! WILL BE OVERWRITTEN IN CASE AT LEAST ONE 'ENTRY' IS DEFINED IN 'ENTRIES' ARRAY. The h5live object to configure the h5live connection.
Properties
Name Type Argument Description serverobject The h5live server object.
Properties
Name Type Argument Description websocketstring <optional>
The h5live websocket url.
progressivestring <optional>
The h5live progressive download url.
hlsstring <optional>
The h5live hls url. Have to be set for playback on iOS 10 or higher. iOS 9 or lower is not supported.
tokenstring <optional>
The h5live server token.
rtmpobject <optional>
The rtmp playout object for h5live playback.
Properties
Name Type Description urlstring The rtmp playout url. Have to include the domain, port and application e.g. 'rtmp://example.com:80/live'.
streamnamestring The rtmp streamname.
securityobject <optional>
The h5live security object for h5live playback.
Properties
Name Type Description tokenstring The security service token.
expiresstring The time the token expires (system time).
optionsstring The security options.
tagstring The custom tag to decrypt the token.
paramsobject <optional>
The params object to pass custom query parameters over the h5live server connection. Parameters can be passed as key/value pairs.
bintuobject <optional>
DEPRECATED. PLEASE USE ENTRIES!!! WILL BE OVERWRITTEN IN CASE AT LEAST ONE 'ENTRY' IS DEFINED IN 'ENTRIES' ARRAY. An bintu object to get sources.
Properties
Name Type Argument Default Description streamidstring The bintu stream id.
apiurlstring <optional>
https://bintu.nanocosmos.de The bintu api url.
hlsstring <optional>
DEPRECATED. PLEASE USE ENTRIES!!! WILL BE OVERWRITTEN IN CASE AT LEAST ONE 'ENTRY' IS DEFINED IN 'ENTRIES' ARRAY. An hls playout url as string.
- See:
Returns:
- Type
- Promise.<(config|error)>
Examples
var source = { "entries": [ { "index": 0, "label": "high", "tag": "this is a high quality stream", "info": { "bitrate": 1200, "width": 1280, "height": 720, "framerate": 30 }, "hls": "", "h5live": { "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYY1" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, "token": "", "security": {} }, "bintu": {} }, { "index": 1, "label": "medium", "tag": "this is a medium quality stream", "info": { "bitrate": 800, "width": 864, "height": 480, "framerate": 30 }, "hls": "", "h5live": { "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYY2" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, "token": "", "security": {} }, "bintu": {} }, { "index": 2, "label": "low", "tag": "this is a low quality stream", "info": { "bitrate": 400, "width": 426, "height": 240, "framerate": 15 }, "hls": "", "h5live": { "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYY3" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, "token": "", "security": {} }, "bintu": {} } ], "options": { "adaption": { "rule": "deviationOfMean2", "downStep": 1 }, "switch": { 'method': 'server', 'pauseOnError': false, 'forcePlay': true, 'fastStart': false, 'timeout': 20 } }, "startIndex": 2 // lowest }; // player instance of NanoPlayer player.updateSource(source).then(function (config) { console.log('update source ok with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); });var source = { "entries": [ { "index": 0, "label": "high", // optional "tag": "this is a high quality stream", // optional "info": { // optional "bitrate": 1200, "width": 1280, "height": 720, "framerate": 30 }, "h5live": { // your rtmp stream "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYYY" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, // optional (secure token) "security": { "token": 'awe456b367g4e6rm8f56hbe6gd8f5m8df6n8idf6tf8mfd68ndi', "expires": '1519819200', "options": '15', "tag": 'anyTag' } } } ] }; // player instance of NanoPlayer player.updateSource(source).then(function (config) { console.log('update source initialized with config: ' + JSON.stringify(config)); }, function (error) { console.log(error); });
Type Definitions
-
config
-
The config object to pass as param for the 'setup' call.
Type:
- object
- See:
Properties:
Name Type Argument Description sourceobject The object to configure the source to play, one of the following properties have to be set.
Properties
Name Type Argument Default Description entriesArray.<NanoPlayer~entry> <optional>
The source entries array for a set of streams. USE INSTEAD OF SOURCE.H5LIVE. Used to configure stream entries. Can have one to many 'entry' objects. Only one existing entry is similar than a single source. In this case no entries options are needed.
startIndexnumber <optional>
0 The index of the entry to start playback with. Can be in the range from 0 to 'entries.length-1'.
defaultsobject <optional>
The object to configure the source entries defaults.
Properties
Name Type Argument Description servicestring <optional>
The defaults service. If a service is set, the
h5live.serverobject and theh5live.rtmp.urlin each entry can be omitted. In this case defaults will be applied internally. Values forh5live.serverand/orh5live.rtmp.urlthat are defined explicitly in the entry have priority. The available value fordefaults.serviceis'bintu'for using the standard nanoStream Cloud.groupobject <optional>
The object to configure a bintu stream group.
Properties
Name Type Argument Description idstring <optional>
The stream group id.
apiurlstring <optional>
The bintu apiurl.
startQualitystring <optional>
The start quality. Will be mapped to a valid
startIndex. Possible values are:'high','medium-high','medium','medium-low','low'. If not set the generalstartIndexof the source will be used (default:0~'high')securityobject <optional>
The security object of the group.
Properties
Name Type Argument Description jwtokenstring <optional>
The JSON Web Token for security.
generalobject <optional>
The object to configure general values.
Properties
Name Type Argument Description serverDomainstring <optional>
The general server domain. It has highest prio and will override/modify all h5live server domains. Possible values are e.g.
bintu-play-eu.nanocosmos.deorbintu-play-ass.nanocosmos.de.optionsobject <optional>
The object to configure the source entries options.
Properties
Name Type Argument Description switchobject <optional>
The object to configure the stream switch options like method etc.
Properties
Name Type Argument Default Description methodstring <optional>
server The update method. Possible values are 'server' (default) and 'client'.
pauseOnErrorboolean <optional>
false If set the player stops if an error occure during the stream switch. Default is false.
forcePlayboolean <optional>
true If set the player starts playback in case the player is paused. Default is true.
fastStartboolean <optional>
false DEPRECATED. Only if method is 'server'. Tries to accelerate the startup time of the new source. Default is false.
timeoutnumber <optional>
20 The timeout for the update source request in seconds. If reached the error 4006 will thrown in the
'onUpdateSourceFail'and the'onSwitchStreamFail'event. Default is 20 seconds, valid range is between 5 and 30.tagstring <optional>
A custom field that can be any string like 'stream-800k' or '720p'. This tag will be returned in any completion event of the 'updateSource' request like 'onUpdateSourceSuccess', 'onUpdateSourceFail' and 'onUpdateSourceAbort'.
adaptionobject <optional>
The object to set an adaption for switching.
Properties
Name Type Argument Default Description rulestring <optional>
none The switch rule if multiple entries are defined. Possible values are 'deviationOfMean' (ABR automatic), 'deviationOfMean2' (ABR automatic) and 'none' (default, means only manual stream switch via 'switchStream' possible).
downStepnumber <optional>
1 The minimum number of steps during a ABR down switch ('deviationOfMean' and 'deviationOfMean2' only).
omitRenditionsArray.<(string|number)> <optional>
The renditions to omit if ABR enabled ('deviationOfMean' and 'deviationOfMean2' only). This parameter accepts an
arrayof valid stream group qualities (e.g.,"high","medium","low") or stream entry indexes (e.g.,0,1,2, etc.).h5liveobject <optional>
DEPRECATED. PLEASE USE ENTRIES!!! WILL BE OVERWRITTEN IN CASE AT LEAST ONE 'ENTRY' IS DEFINED IN 'ENTRIES' ARRAY. The h5live object to configure the h5live connection.
Properties
Name Type Argument Description serverobject The h5live server object.
Properties
Name Type Argument Description websocketstring <optional>
The h5live websocket url.
progressivestring <optional>
The h5live progressive download url.
hlsstring <optional>
The h5live hls url. Have to be set for playback on iOS 10 or higher. iOS 9 or lower is not supported.
tokenstring <optional>
The h5live server token.
rtmpobject <optional>
The rtmp playout object for h5live playback.
Properties
Name Type Description urlstring The rtmp playout url. Have to include the domain, port and application e.g. 'rtmp://example.com:80/live'.
streamnamestring The rtmp streamname.
securityobject <optional>
The h5live security object for h5live playback.
Properties
Name Type Description tokenstring The security service token.
expiresstring The time the token expires (system time).
optionsstring The security options.
tagstring The custom tag to decrypt the token.
paramsobject <optional>
The params object to pass custom query parameters over the h5live server connection. Parameters can be passed as key/value pairs.
bintuobject <optional>
DEPRECATED. PLEASE USE ENTRIES!!! WILL BE OVERWRITTEN IN CASE AT LEAST ONE 'ENTRY' IS DEFINED IN 'ENTRIES' ARRAY. An bintu object to get sources.
Properties
Name Type Argument Default Description streamidstring The bintu stream id.
apiurlstring <optional>
https://bintu.nanocosmos.de The bintu api url.
hlsstring <optional>
DEPRECATED. PLEASE USE ENTRIES!!! WILL BE OVERWRITTEN IN CASE AT LEAST ONE 'ENTRY' IS DEFINED IN 'ENTRIES' ARRAY. An hls playout url as string.
playbackobject <optional>
The object to configure the playback.
Properties
Name Type Argument Default Description autoplayboolean <optional>
true Enable/disable autoplay (default: true).
IMPORTANT: Browsers (mostly mobile) with stricter autoplay policy only allow autoplay with muted audio or within a user interaction (tap, click etc.). To allow autoplay in this case set the 'muted' property to 'true'. See our nanocosmos-blog for more informations.automuteboolean <optional>
true Enable/disable automute (default: false).
IMPORTANT: Browsers (mostly mobile) with stricter autoplay policy only allow autoplay with muted audio or within a user interaction (tap, click etc.). With 'autoplay = true' and this option enabled the player will be muted to allow autoplay in case the browsers policy restricted autoplay.mutedboolean <optional>
false Mute/unmute the player (default: false).
IMPORTANT: Browsers (mostly mobile) with stricter autoplay policy only allow autoplay with muted audio. To allow autoplay set the 'muted' property to 'true'. See property 'autoplay' for more informations.latencyControlModestring <optional>
balancedadaptive The latency control mode of the player - possible values: "classic", "fastadaptive", "balancedadaptive"
metadataboolean <optional>
false Enable/disable metadata (default: false).
enableMediaOverQuicstring <optional>
Enable/disable Media Over Quic playback (default: true).
enableQuicConnectionProbestring <optional>
Enable/disable Media Over Quic connection probe (default: true). If Media Over Quic playback is disabled, the probe functionality is not used.
videoIdstring | Array.string <optional>
One or two element ids of existing video tags that should be used for playback. No new element(s) will be created and after destroy it/they will be kept. Can be a string (old, only one element) or a string array with one or two (HLS PLAYBACK ONLY!) element ids. Two video elements are required only for stream switching on iOS, MSE playback uses only one video tag. If only one element id is given on iOS the second video tag will be created by the player.
keepConnectionboolean <optional>
false If enabled the player will have always a connection to the h5live server. NOTE: not recommended for general use
allowSafariHlsFallbackboolean <optional>
false If enabled the player will select the playback method in Safari Mac OS X and utilize H5Live low latency HLS if appropriate.
crossOriginstring <optional>
not-set Sets or disables the native "crossOrigin" attribute for all internal video elements and images (poster). Possible values are "anonymous", "use-credentials" and "not-set" (default). If "not-set" is used the attribute will not be added.
mediaErrorRecoveriesnumber <optional>
3 The number of allowed media error recoveries within a minute. If threshold is reached the last error will be thrown and playback pauses. Possible recoverable error codes are 3003 (decode error), 3100 (media source ended) and 1008 (hls playback error). See
errorcodes.metadataLowDelayboolean <optional>
true If enabled this mode for metadata processing is preventing occasionally delayed metadata on iOS. To use legacy mode set to false. The setting
playback.metadatahas to be enabled. HLS PLAYBACK ONLYfaststartboolean <optional>
true If enabled the fast start mode is reducing the time to first frame and the playback start time.
reconnectobject <optional>
The reconnect object to configure the reconnect settings. See
errorcodesfor reconnect possibility.Properties
Name Type Default Description minDelaynumber 2 The minimum time to reconnect in seconds. The lowest possible value is 1 sec.
maxDelaynumber 10 The maximum time to reconnect in seconds.
delayStepsnumber 10 This number of steps till the maximum delay should reached.
maxRetriesnumber 10 The maximum count of reconnect tries. If set to zero no reconnect will be done.
timeoutsobject <optional>
The timeouts object to configure the timeouts for playback.
Properties
Name Type Default Description loadingnumber 20 The timeout for the loading state in seconds, range from 10 - 60 seconds. If reached the player will be stopped with reason 'streamnotfound' and error 2001 will be thrown. Will be cleared if player goes to playing state.
bufferingnumber 20 The timeout for the buffering state in seconds, range from 10 - 60 seconds. If reached the player will be stopped with reason 'buffer' and error 2002 will be thrown. Will be cleared if player goes to playing state again.
connectingnumber 5 The timeout for establishing the websocket connection, range from 5 - 30 seconds. If reached the player will be stopped with reason 'connectionclose' and error 4106 will be thrown. WEBSOCKET ONLY, FOR HLS PLAYBACK ONLY IF METADATA IS ENABLED
styleobject <optional>
The object to configure the style of the player.
Properties
Name Type Argument Default Description widthstring <optional>
640px The width of the player in pixels (e.g 320px) or percentage (80%) (height or aspectratio have to be set too). Use 'auto' to keep the parents size (height and aspectratio have no effect).
heightstring <optional>
The height of the player in pixels (e.g 240px) or percentage (45%) (width or aspectratio have to be set too). Use 'auto' to keep the parents size (width and aspectratio have no effect).
aspectratiostring <optional>
16/9 The aspectratio of the player (e.g. 16/9) (width or height have to be set too).
controlsboolean <optional>
true Show/hide video controls.
interactiveboolean <optional>
true Enable/disable interactivity of the player on click/touch.
viewboolean <optional>
true Enable/disable view port handling/animations.
scalingstring <optional>
letterbox Set's the display mode for the video inside the player - possible values: "letterbox", "fill", "crop", "original", "resize".
keepFrameboolean <optional>
true If true the last played frame will be displayed after a pause.
displayAudioOnlyboolean <optional>
true If true a audio symbol will be shown in case of a stream with audio only.
audioPlayerboolean <optional>
false If true a player will be created as an audio player without video functionality. Controls can be enabled/disabled. The size can be customized via 'width' and 'height'. Default is 640px * 51px.
displayMutedAutoplayboolean <optional>
true If true a muted audio symbol will be shown in case of muted autoplay.
fullScreenControlboolean <optional>
true If true shows fullscreen control symbol in player controls.
backgroundColorstring <optional>
black Sets the background color of the video element - possible values: html colors ("red", "blue", ...), hex color codes ("#FACAFD", "#FCEC66", ...) and rgba color values ("rgba(255,0,0,1)", "rgba(0,255,0,0.7)", ...).
centerViewboolean <optional>
true Enable/disable the animations and icons in the center of the player's view.
symbolColorstring <optional>
rgba(244,233,233,1) Sets the color of the symbols used in centerView and controls - The given color string can be a valid css (case insensitive) keyword, hex code with/without alpha, rgb, rgba, hsl or hsla. Example values: "white", "#ffffff", "rgba(237,125,14,0.5)".
controlBarColorstring <optional>
rgba(0,0,0,0.5) Sets the color of the control bar - The given color string can be a valid css (case insensitive) keyword, hex code with/without alpha, rgb, rgba, hsl or hsla. Example values: "white", "#ffffff", "rgba(237,125,14,0.5)".
buttonAnimationboolean <optional>
true If true all buttons have short animations at 'mouseover' and 'click'.
buttonHighlightingboolean <optional>
true If true all buttons are slightly highlighted at hover.
buttonCursorstring <optional>
pointer Sets the cursor of all buttons. Possible values are valid css cursor values like 'default' or 'pointer'.
posterstring <optional>
Sets a poster image to the player that is visible before and after playback. That can be every valid source of an IMG element. Valid sources are e.g. './assets/poster.png' or 'https://[YOURDOMAIN]/assets/poster.gif'. The poster will be displayed 'letterbox'.
fullScreenBackgroundColorstring <optional>
inherit Sets the background color in fullscreen mode of the video element. If not set it inherits from
style.backgroundColor- possible values: html colors ("red", "blue", ...), hex color codes ("#FACAFD", "#FCEC66", ...) and rgba color values ("rgba(255,0,0,1)", "rgba(0,255,0,0.7)", ...).eventsobject <optional>
The object to set handlers to the player events.
Properties
Name Type Argument Description onReadyfunction <optional>
Fires if the player is ready to play after successful setup.
onPlayfunction <optional>
Fires if playout is started.
onPausefunction <optional>
Fires if playout is paused.
onLoadingfunction <optional>
Fires if playout was stopped or player is ready after setup and tries to play.
onStartBufferingfunction <optional>
Fires if playout is started but no media is available.
onStopBufferingfunction <optional>
Fires if playout resumes after buffering.
onErrorfunction <optional>
Fires if any kind of error occures.
onStatsfunction <optional>
Fires if the player has measured statistics.
onMetaDatafunction <optional>
Fires if the player has received metadata.
onMutefunction <optional>
Fires if the player is muted.
onUnmutefunction <optional>
Fires if the player is unmuted.
onVolumeChangefunction <optional>
Fires if the player's volume has changed.
onStreamInfofunction <optional>
Fires if stream info is available.
onStreamInfoUpdatefunction <optional>
Fires if stream info of a stream is updated during playback.
onWarningfunction <optional>
Fires if something is not as expected, but functionality works.
onDestroyfunction <optional>
Fires if the player is destroyed.
onUpdateSourceInitfunction <optional>
Fires if the player has received an update source request.
onUpdateSourceSuccessfunction <optional>
Fires if the player has successfully updated the source.
onUpdateSourceFailfunction <optional>
Fires if the player has failed to update the source.
onUpdateSourceAbortfunction <optional>
Fires if the player aborted the update source request.
onServerInfofunction <optional>
Fires if h5live server info is available.
onFullscreenChangefunction <optional>
Fires if the fullscreen mode of the player has changed.
tweaksobject <optional>
The object to tweak the player (only h5live).
Properties
Name Type Argument Description bufferobject <optional>
The bufffer object.
Properties
Name Type Description minnumber The minimum time to buffer.
startnumber The buffer time when the playout starts.
targetnumber The target buffer time.
limitnumber The buffer time limit before increase play speed.
maxnumber The maximum time to buffer.
bufferDynamicobject <optional>
The bufffer dynamic object.
Properties
Name Type Description offsetThresholdnumber The threshold time between two bufferings in seconds. If the measured value is lower, the buffer will be increased by offsetStep.
offsetStepnumber The step to increase in seconds. Also the step to decrease in cooldown.
cooldownTimenumber The time to check stable playback. If stable playback is detected, the buffer values will be decreased till original buffer values are reached.
metricsobject <optional>
The metrics object. Only usable with valid account. Configuring this object allows you to collect and analyse data via the 'nanoStream Cloud'. If not set, metrics are disabled. See our nanocosmos / nanoStream documentation for more informations.
Properties
Name Type Argument Default Description accountIdstring The account id provided by nanocosmos to use with the metrics.
accountKeystring The account key provided by nanocosmos to use with the metrics.
serverDomainstring <optional>
The server domain to use with the metrics. e.g. "metrics.stream360.io".
userIdstring <optional>
Application user/viewer id. If your application includes a user name or user id, providing this information enables you to filter or aggregate data by this user.
eventIdstring <optional>
Application event id. If the stream is related to a certain event, e.g. webinar, auction or sports event, providing this information enables you to filter or aggregate data by this event.
statsIntervalnumber <optional>
10 The interval how often the stats should be collected in seconds. The minimum is 5 seconds..
customField*string <optional>
Custom field. * can be replaced with 1 - 10 e.g. 'customField3'. Possible from 'customField1' to 'customField10'.
Examples
// stream group config example var config = { "source" : { "group": { "id": "3b6cca80-91ca-49f1-b7da-6486317ac077", "startQuality": "low" } }, "playback": { "autoplay": true, "automute": true, "muted": false, "metadata": true, "faststart": true, "latencyControlMode": 'balancedadaptive' }, "events": { "onError": function (e) { console.log(e); } }, "style": { "width": 'auto', "height": 'auto' } };// example with bintu as default service var config = { "source": { "defaults": { "service": 'bintu' }, "entries": [ // array of 'entry' objects { "index": 0, "label": "high", "h5live": { "rtmp": { "streamname": "XXXXX-YYYY1" } } }, { "index": 1, "label": "medium", "h5live": { "rtmp": { "streamname": "XXXXX-YYYY2" } } }, { "index": 2, "label": "low", "h5live": { "rtmp": { "streamname": "XXXXX-YYYY3" } } } ], "options": { "adaption": { "rule": "deviationOfMean2" } }, "startIndex": 2 // lowest }, "playback": { "autoplay": true, "automute": true, "muted": false, "faststart": true, "latencyControlMode": 'balancedadaptive' }, "events": { "onStats": function (e) { console.log(e); } }, "style": { view: false }, "metrics": { "accountId": 'myId', "accountKey": 'sdfhe457zsjhnrtzd8' } };// complete config example var config = { "source" : { "entries": [ // array of 'entry' objects { "index": 0, "label": "high", "tag": "this is a high quality stream", "info": { "bitrate": 1200, "width": 1280, "height": 720, "framerate": 30 }, "hls": "", "h5live": { "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYY1" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, "token": "", "security": {} }, "bintu": {} }, { "index": 1, "label": "medium", "tag": "this is a medium quality stream", "info": { "bitrate": 800, "width": 864, "height": 480, "framerate": 30 }, "hls": "", "h5live": { "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYY2" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, "token": "", "security": {} }, "bintu": {} }, { "index": 2, "label": "low", "tag": "this is a low quality stream", "info": { "bitrate": 400, "width": 426, "height": 240, "framerate": 15 }, "hls": "", "h5live": { "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYY3" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, "token": "", "security": {} }, "bintu": {} } ], "options": { "adaption": { "rule": "deviationOfMean2", "downStep": 2 }, "switch": { 'method': 'server', 'pauseOnError': false, 'forcePlay': true, 'fastStart': false, 'timeout': 20 } }, "startIndex": 2 // lowest }, // playback is completely optional "playback": { "autoplay": true, "automute": true, "muted": false, "faststart": true, "latencyControlMode": 'balancedadaptive', "metadata": true, "reconnect": { "minDelay": 2.5, "maxDelay": 12.5, "delaySteps": 6, "maxRetries": 20 }, "videoId": ['myVideoTagId', 'myVideoTagId'] }, "events": { "onWarning": function (e) { console.log(e); } }, "style": { "width": '1280px', "height": '720px' }, // optional buffer tweaks, use with care, usually not required "tweaks": { "buffer": { "min": 0.2, "start": 0.5, "max": 8.0, "target": 1.2, "limit": 1.7 } }, // metrics/analytics (requires account) "metrics": { "accountId": 'myId', "accountKey": 'sdfhe457zsjhnrtzd8', "userId": 'myUserId', "eventId": 'myEventId', "statsInterval": 10, "customField1": 'custom', "customField2": 42, "customField3": true } };var config = { "source" : { "entries": [ // array of 'entry' objects, here only one is defined as single source { "index": 0, "label": "high", // optional "tag": "this is a high quality stream", // optional "info": { // optional "bitrate": 1200, "width": 1280, "height": 720, "framerate": 30 }, "hls": "", "h5live": { "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYYY" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, // (optional) secure token "security": { "token": 'awe456b367g4e6rm8f56hbe6gd8f5m8df6n8idf6tf8mfd68ndi', "expires": '1519819200', "options": '15', "tag": 'anyTag' } } } ], "options": { // optional "adaption": { "rule": "none" } }, "startIndex": 0 // optional }, "playback": { "autoplay": true, "muted": true }, "events": { "onReady": function (e) { console.log('player ready with ' + JSON.stringify(e)); }, "onPlay": function (e) { console.log('playing'); console.log('play stats: ' + JSON.stringify(e.data.stats)); }, "onPause": function (e) { console.log('pause'); if (e.data.reason !== 'normal') { alert('Paused with reason: ' + e.data.reason); } }, "onError": function (e) { try { var err = JSON.stringify(e); if (err === '{}') { err = e.message; } e = err; } catch (err) { } console.log(e); alert(e); }, "onMetaData": function (e) { console.log(e); }, "onStats": function (e) { console.log(e); }, "onStreamInfo": function (e) { console.log(e); }, "onDestroy": function (e) { console.log(e); } }, "style": { "width: '1280px', "aspectratio": '16/9', "controls": false, "scaling": 'crop' } }; -
entry
-
An entry object to pass stream parameters like h5live config, stream informations etc. in the 'config.source.entries' array
Type:
- object
- See:
Properties:
Name Type Argument Description indexnumber The index of the stream entry. Have to be the same as the position in the 'entries' array. Begins with '0'.
labelstring <optional>
A custom label for the stream e.g. 'high'.
tagstring <optional>
Custom informations about the stream entry.
infoobject <optional>
The info object to set stream meta data.
Properties
Name Type Default Description bitratenumber 0 The stream bitrate.
widthnumber 0 The stream width.
heightnumber 0 The stream height.
frameratenumber 0 The stream framerate.
hlsstring <optional>
An hls playout url as string.
h5liveobject <optional>
The h5live object to configure the h5live connection.
Properties
Name Type Argument Description serverobject The h5live server object.
Properties
Name Type Argument Description websocketstring The h5live websocket url.
progressivestring <optional>
The h5live progressive download url.
hlsstring The h5live hls url. Have to be set for playback on iOS 10 or higher. iOS 9 or lower is not supported.
tokenstring <optional>
The h5live server token.
rtmpobject The rtmp playout object for h5live playback.
Properties
Name Type Description urlstring The rtmp playout url. Have to include the domain, port and application e.g. 'rtmp://example.com:80/live'.
streamnamestring The rtmp streamname.
securityobject <optional>
The h5live security object for h5live playback.
Properties
Name Type Description tokenstring The security service token.
expiresstring The time the token expires (system time).
optionsstring The security options.
tagstring The custom tag to decrypt the token.
paramsobject <optional>
The params object to pass custom query parameters over the h5live server connection. Parameters can be passed as key/value pairs.
bintuobject <optional>
An bintu object to get sources.
Properties
Name Type Argument Default Description streamidstring The bintu stream id.
apiurlstring <optional>
https://bintu.nanocosmos.de The bintu api url.
Examples
var source = { "entries": [ { "index": 0, "label": "high", "tag": "this is a high quality stream", "info": { "bitrate": 1200, "width": 1280, "height": 720, "framerate": 30 }, "hls": "", "h5live": { "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYY1" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, "token": "", "security": {} }, "bintu": {} }, { "index": 1, "label": "medium", "tag": "this is a medium quality stream", "info": { "bitrate": 800, "width": 864, "height": 480, "framerate": 30 }, "hls": "", "h5live": { "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYY2" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, "token": "", "security": {} }, "bintu": {} }, { "index": 2, "label": "low", "tag": "this is a low quality stream", "info": { "bitrate": 400, "width": 426, "height": 240, "framerate": 15 }, "hls": "", "h5live": { "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYY3" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, "token": "", "security": {} }, "bintu": {} } ], "options": { "adaption": { "rule": "deviationOfMean2", "downStep": 1 }, "switch": { 'method': 'server', 'pauseOnError': false, 'forcePlay': true, 'fastStart': false, 'timeout': 20 } }, "startIndex": 2 // lowest };var source = { "entries": [ { "index": 0, "label": "high", // optional "tag": "this is a high quality stream", // optional "info": { // optional "bitrate": 1200, "width": 1280, "height": 720, "framerate": 30 }, "h5live": { // your rtmp stream "rtmp": { "url": "rtmp://bintu-play.nanocosmos.de/play", "streamname": "XXXXX-YYYYY" }, "server": { "websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4", "hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8", "progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4" }, // optional (secure token) "security": { "token": 'awe456b367g4e6rm8f56hbe6gd8f5m8df6n8idf6tf8mfd68ndi', "expires": '1519819200', "options": '15', "tag": 'anyTag' } } } ] }; -
errorcode
-
The possible error codes in a onError event.
Type:
- number
- See:
Properties:
Name Type Description 1000-1999PlayerError Properties
Name Type Description 1001No rtmp url set.
1002No server set.
1003Could not play because player has not been configured.
1004Could not pause because player was not in playing state before.
1005Playback must be initialized by user gesture.
1006Buffer config is invalid.
1007Playback suspended by external reason.
1008Playback error.
1009Playback failed because the player was in visibility state 'hidden' at load start.
1010The given stream entry index is not valid. (see
switchStream)2000-2999StreamError Properties
Name Type Description 2001The requested stream can not be found.
2002No media available.
2003Not enough media data received. The stream was already connected and the stream info event was fired.
2004The source stream has been stopped.
2011Received metadata with wrong index.
2012Received metadata with invalid json string.
2013Received metadata but no start index.
2014Received metadata with start index but currently process another.
3000-3999MediaError Properties
Name Type Description 3001A fetching process of the media aborted by user.
3002An error occurred when downloading media.
3003An error occurred when decoding media.
3004The received audio/video is not supported.
3005An error occurred while hls playback when decoding video.
3100The media source extension changed the state to 'ended'. NOT AVAILABLE FOR HLS PLAYBACK.
3101An error occurred while buffering on hls playback.
3102Buffer range is higher than allowed on hls playback.
3200An unspecific media error occurred.
4000-4999NetworkError Properties
Name Type Description 4000-4099General Properties
Name Type Description 4001Could not establish connection. Maybe wrong protocol or path.
4002Connection error.
4003Maximum number of reconnection tries reached.
4004Reconnection configuration invalid.
4005The requested source stream has been stopped.
4006The source request was aborted by timeout.
4100-4199WebSocket Properties
Name Type Description 4101An endpoint is "going away", such as a server going down or a browser having navigated away from a page.
4102An endpoint is terminating the connection due to a protocol error. Reconnect possible.
4103An endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message). Reconnect possible.
4104Reserved. The specific meaning might be defined in the future.
4105No status code was actually present. Reconnect possible.
4106Maybe no network, wrong url or server down. Reconnect possible.
4107An endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [http://tools.ietf.org/html/rfc3629] data within a text message). Reconnect possible.
4108An endpoint is terminating the connection because it has received a message that "violates its policy". This reason is given either if there is no other sutible reason, or if there is a need to hide specific details about the policy. Reconnect possible.
4109An endpoint is terminating the connection because it has received a message that is too big for it to process. Reconnect possible.
4110An endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake.
4111A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request. Reconnect possible.
4115The connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified). Reconnect possible.
4400-4499Http Properties
Name Type Description 4400Bad request. Maybe stream parameters are missing or malformed.
4403Access denied. The authentication token is missing or invalid.
4500The connection has been rejected due an internal server error. Reconnect possible.
4503The requested service is currently unavailable. Reconnect possible.
4900-4999Security Properties
Name Type Description 4900The security service has been rejected due an internal server error.
4901The security service denied access. The authentication token is invalid.
4903The security service denied access. The url is expired or a token parameter is missing (expires, token, or options).
4904The security service can not be found.
5000-5999SetupError Properties
Name Type Description 5000-5099General Properties
Name Type Description 5001An exception was thrown during setup.
5002This browser does not fully support HTML5 and H5Live. Supported are: Chrome >=54 (Windows, MacOSX, Android), Firefox >=48 (Windows, MacOSX, Android), Microsoft Edge (Windows), Microsoft Internet Explorer 11 (at least Windows 8), Safari (MacOSX & at least iOS 10).
5003A forced tech is not supported by your browser.
5004The players source configuration is malformed or missing.
5005Configuration error. Could not create/update player, the rtmp configuration is missing or incomplete. Add an rtmp url and streamname to the configuration.
5006Configuration error. Could not create/update player, with this configuration an security token is required. Add an token to the configuration.
5007Configuration error. Could not create/update player, the websocket server configuration is missing.
5008Configuration error. Could not create/update player, the hls server configuration is missing.
5009Configuration error. Could not create/update player, the websocket server configuration for metadata is missing.
5010Could not embed player.
5100-5199Bintu Properties
Name Type Description 5101Could not find bintu stream. The stream is not live.
5102No bintu stream id passed.
5103Bintu service rejected.
5200-5299Metrics Properties
Name Type Description 5201Metrics configuration error. No metrics config object passed.
5202Metrics configuration error. Metrics config is not from type 'object'.
5203Metrics configuration error. Metrics config is empty.
5204Metrics configuration error. A custom property has no valid index number, the range is 1 to 10 e.g.'customField1'.
5205Metrics configuration error. A custom property is not indexed correctly, the range is 1 to 10 e.g.'customField1'.
5206Metrics configuration error. A custom property has an index out of range, the range is 1 to 10 e.g.'customField1'.
5207Metrics configuration error. A property is not valid.
5208Metrics configuration error. No credentials passed.
-
pausereason
-
The possible pause reason in a onPause event.
Type:
- string
- See:
Properties:
Name Type Description normalPaused by user.
bufferPaused by buffer timeout. The stream was stopped or there was a buffer underrun.
connectionclosePaused by network connection close.
servernotfoundPaused because of the h5live server was not found.
streamnotfoundPaused by loading timeout. The stream could not found.
interactionrequiredPaused because auto playback is denied. Can happen especially on mobile.
playbacksuspendedPaused because the playback was suspended by an external reason.
playbackerrorPaused because the playback had an error.
reconnectionimminentPaused because the connection was closed by an external reason and a reconnect will be prepared.
destroyPaused because the player will be destroyed.
playbackrestartPaused because the player was stopped for update source. The player will restart immediately.
visibilityhiddenPaused because the player was not visible at load start.
notenoughdataPaused by loading timeout. The stream was alive and connected but not enough data was received to start playback.
sourcestreamstoppedPaused because the source stream has been stopped.
-
state
-
The state of the player.
Type:
- number
- See:
Properties:
Name Type Description 1UNINITIALIZED
2IDLE
3READY
4LOADING
5PLAYING
6PAUSED
7BUFFERING
8UNKNOWN
9PLAYBACK_NOT_STARTED
10PLAYBACK_SUSPENDED
11PAUSING
12PLAYBACK_ERROR
13RECONNECTION_IMMINENT
14CONNECTION_ERROR
15DESTROYING
16PLAYBACK_RESTARTING
17VISIBILITY_HIDDEN
18NOT_ENOUGH_DATA
19SOURCE_STREAM_STOPPED
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); });