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:
-
- 3.18.7
Examples
<!-- Example: load player with new video element into playerDiv -->
<div id="playerDiv"></div>
<script type="text/javascript" src="nanoplayer.4.min.js"></script>
<script type="text/javascript">
var player;
var config = {
source: {
h5live: {
// h5live server endpoint (not required to change)
server: {
websocket: 'wss://bintu-h5live.nanocosmos.de/h5live/stream',
hls: 'https://bintu-h5live.nanocosmos.de/h5live/http/playlist.m3u8'
},
// rtmp stream source (your live stream)
rtmp: {
url: 'rtmp://bintu-play.nanocosmos.de:80/live',
streamname: 'XXXXX-YYYYY'
}
}
}
};
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>
</div>
<script>
var player;
var config = {
source: {
h5live: {
// h5live server endpoint (not required to change)
server: {
websocket: 'wss://bintu-h5live.nanocosmos.de/h5live/stream',
hls: 'https://bintu-h5live.nanocosmos.de/h5live/http/playlist.m3u8'
},
// rtmp stream source (your live stream)
rtmp: {
url: 'rtmp://bintu-play.nanocosmos.de:80/live',
streamname: 'XXXXX-YYYYY'
}
}
},
playback: {
videoId: 'myPlayer'
}
};
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.3.min'
// if 'baseUrl' is defined a local path have to be relative to the base path
nanoplayer: '//demo.nanocosmos.de/nanoplayer/api/nanoplayer.4.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
-
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);
-
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();
-
setup(config) → {Promise.<(config|error)>}
-
Initializes the player with a given config object.
Parameters:
Name Type Description configconfig 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.
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);
-
unmute()
-
Unmutes the player.
Example
// player instance of NanoPlayer player.unmute();
-
updateSource(source, options) → {Promise.<(config|error)>}
-
Updates the source of the player.
Parameters:
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 Description 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 <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>
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>
An hls playout url as string.
optionsobject <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 Only if method is 'server'. Tries to accelerate the startup time of the new source. Default is false.
timeoutnumber <optional>
10 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'.
Returns:
- Type
- Promise.<(config|error)>
Example
var source = { h5live: { // h5live server endpoint (not required to change) server: { websocket: 'wss://bintu-h5live.nanocosmos.de/h5live/stream', hls: 'https://bintu-h5live.nanocosmos.de/h5live/http/playlist.m3u8' }, // rtmp stream source (your live stream) rtmp: { url: 'rtmp://bintu-play.nanocosmos.de:80/live', streamname: 'XXXXX-YYYYY' }, security: { token: 'awe456b367g4e6rm8f56hbe6gd8f5m8df6n8idf6tf8mfd68ndi', expires: '1519819200', options: '15', tag: 'anyTag' } } } var options = { method: 'server', pauseOnError: false, forcePlay: true, fastStart: false, timeout: 10, tag: 'XXXXX-YYYYY' } // player instance of NanoPlayer player.updateSource(source, options).then(function (config) { console.log('update source ok 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 Description 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 <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>
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>
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>
false 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.metadataboolean <optional>
false Enable/disable metadata (default: false).
forceTechstring <optional>
Force the player to use this tech - possible values: "h5live", "flash", "hls.native"
flashplayerstring <optional>
A absolute or relative path to the "nano.player.swf". If not set the player will be required from the base path.
videoIdstring <optional>
An element id of a existing video tag that should be used for playback. No new element will be created and after destroy it will be kept.
keepConnectionboolean <optional>
false If enabled the player will have always a connection to the h5live server.
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.
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 IOS 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>
false 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)", ...).
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.
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.
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.
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 1 second.
customField*string <optional>
Custom field. * can be replaced with 1 - 10 e.g. 'customField3'. Possible from 'customField1' to 'customField10'.
Examples
var config = { source: { bintu: { streamid: 'q23rf2tzw3h6754iretmft7irt' } } };// Complete config example var config = { source: { h5live: { // h5live server endpoint (not required to change) server: { websocket: 'wss://bintu-h5live.nanocosmos.de/h5live/stream', hls: 'https://bintu-h5live.nanocosmos.de/h5live/http/playlist.m3u8' }, // rtmp stream source (your live stream) rtmp: { url: 'rtmp://bintu-play.nanocosmos.de:80/live', streamname: 'XXXXX-YYYYY' }, // (optional) secure token security: { token: 'awe456b367g4e6rm8f56hbe6gd8f5m8df6n8idf6tf8mfd68ndi', expires: '1519819200', options: '15', tag: 'anyTag' } } }, // playback is completely optional playback: { autoplay: false, metadata: true, keepConnection: true, reconnect: { minDelay: 2.5, maxDelay: 12.5, delaySteps: 6, maxRetries: 20 } }, 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 }, bufferDynamic: { offsetThreshold: 2, offsetStep: 0.5, cooldownTime: 10 } }, // metrics/analytics (requires account) metrics: { accountId: 'myId', accountKey: 'sdfhe457zsjhnrtzd8', userId: 'myUserId', eventId: 'myEventId', statsInterval: 10, customField1: 'custom', customField2: 42, customField3: true } };// example with source url params and events var config = { source: { h5live: { server: { websocket: 'wss://bintu-h5live.nanocosmos.de/h5live/stream', hls: 'https://bintu-h5live.nanocosmos.de/h5live/http/playlist.m3u8' }, // rtmp stream source (your live stream) params: { url: 'rtmp://bintu-play.nanocosmos.de:80/live', streamname: 'XXXXX-YYYYY' custom_key: 'custom_value' } } }, playback: { autoplay: false, videoId: 'myVideoTagId' }, events: { onStats: function (e) { console.log(e); } }, style: { view: false }, metrics: { accountId: 'myId', accountKey: 'sdfhe457zsjhnrtzd8' } };var config = { source: { h5live: { // h5live server endpoint (not required to change) server: { websocket: 'wss://bintu-h5live.nanocosmos.de/h5live/stream', hls: 'https://bintu-h5live.nanocosmos.de/h5live/http/playlist.m3u8' }, // rtmp stream source (your live stream) rtmp: { url: 'rtmp://bintu-play.nanocosmos.de:80/live', streamname: 'XXXXX-YYYYY' } }, token: "{\"type\":\"token1\",\"key\":\"exampleToken\"}" }, 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' } }; -
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.
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.
3100The media source extension changed the state to 'ended'. NOT AVAILABLE FOR IOS.
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 in the 'updateSource' call has been stopped.
4006The update 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.
5002A forced tech is not supported by your browser.
5003The players source configuration is malformed or missing.
5004This 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).
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
-
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 Description codeNanoPlayer~errorcode The error code.
messagestring The error cause as human readable string.
stateNanoPlayer~state The player state.
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
- 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); }); -
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 IOS.
avgnumber The average bitrate in Bit/s over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.
minnumber The minimum bitrate in Bit/s over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.
maxnumber The maximum bitrate in Bit/s over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.
framerateobject The framerate object.
Properties
Name Type Description currentnumber The current network framerate. Is '0' if not available. NOT AVAILABLE FOR IOS.
avgnumber The average network framerate over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.
minnumber The minimum network framerate over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.
maxnumber The maximum network framerate over the last 10 seconds. Is '0' if not available. NOT AVAILABLE FOR IOS.
qualityobject The video playback quality object.
Properties
Name Type Description corruptedVideoFramesnumber The total number of corrupted video frames. ONLY AVAILABLE FOR FIREFOX.
corruptedVideoFramesCurrentnumber The number of corrupted video frames within the last second. ONLY AVAILABLE FOR FIREFOX.
creationTimenumber The time in miliseconds since the start of the navigation and the creation of the video element. ONLY AVAILABLE FOR FIREFOX.
droppedVideoFramesnumber The total number of dropped video frames. ONLY AVAILABLE FOR FIREFOX.
droppedVideoFramesCurrentnumber The number of dropped video frames within the last second. ONLY AVAILABLE FOR FIREFOX.
totalVideoFramesnumber The total number of created and dropped video frames since creation of the video element. ONLY AVAILABLE FOR FIREFOX.
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.
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 IOS.
sampleRatenumber | null The audio sample rate. Is 'null' if not available. NOT AVAILABLE FOR IOS.
channelsnumber | null The number of audio channels. Is 'null' if not available. NOT AVAILABLE FOR IOS.
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 IOS.
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 IOS.
sampleRatenumber | null The audio sample rate. Is 'null' if not available. NOT AVAILABLE FOR IOS.
channelsnumber | null The number of audio channels. Is 'null' if not available. NOT AVAILABLE FOR IOS.
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 IOS.
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
- 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 ('updatefrequency'). 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 reasonstring The options object used for the
'updateSource'call. Possible values are 'equalsource', 'superseded' and 'updatefrequency'.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'stateNanoPlayer~state The player state.
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
- 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 codeobject The error code. Similar to the
errorcodes.messageobject The error message.
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'stateNanoPlayer~state The player state.
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
- 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 source object given in the
'updateSource'call.optionsobject The options object used for the
'updateSource'call.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'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 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'stateNanoPlayer~state The player state.
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
- 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); });