Skip to main content

The MistVideo object

These methods and properties can be found directly on the MistVideo object and may be used to control the meta-player.

MistVideo.stream

This property contains the stream name as a string. It should be considered read only.

MistVideo.options

This property contains the options passed to the meta-player. It should be considered read only.

MistVideo.info

This property contains the stream information as an object once the meta-player has loaded the stream meta data from MistServer. It should be considered read only.

MistVideo.playerName

This property contains the name of the selected player as a string once the meta-player has selected one. It should be considered read only.

MistVideo.source

This property contains the selected source as an object once the meta-player has selected one. It should be considered read only.

MistVideo.video

This property contains the video element once the player has constructed it.

It can be used to add event listeners to, but the element's methods and properties should not be used directly. These should be accessed through MistVideo.player.api.

MistVideo.logs

This property contains any log messages this meta-player instance has sent, as an array. Each log entry is an object, with a time key containing a Date object of when it was dispatched, a message key containing the message itself, and a data key, which contains an object with at least a type key, which is either "log" or "error".

It should be considered read only. Use the MistVideo.log() method to add new messages.

MistVideo.timers

In this property, timers associated with this meta-player instance are stored as an object. When the instance is unloaded all the timers are automatically canceled.

To start a timer, use MistVideo.timers.start(callback,delay). A timer id is returned, just like JavaScript's own setTimeout function does. To cancel the timer, use MistVideo.timers.stop(timer_id).

MistVideo.monitor

This property contains the stream playback monitor, comprised of the default monitor extended with custom code that was passed through the monitor option (See metaplayer options monitor ). It should be considered read only.

MistVideo.nextCombo()

When this method is called, the meta-player instance will be reloaded, using the next best source / player combination. If all combinations have been tried, it will loop from the beginning.

MistVideo.unload()

When this method is called, the video is stopped and the meta-player is removed from the web page. Any running processes may fail to complete.

MistVideo.log(message,type)

When this method is called, a message is added to the log. The type parameter is optional and defaults to "log".

MistVideo.checkCombo(options,quiet)

This method can be used to determine if a source and player combination is available, and if so, which the meta-player would choose.

options should be an object containing options as they would be passed to mistPlay, and defaults to the options used to start the current instance.

If quiet evaluates to true, the usual log messages when choosing a source / player combo won't be sent.

The return value is an object, with these keys:

  • player
    The name of the selected player

  • source
    The selected source object

  • source_index
    The index of the selected source

MistVideo.showError(message,options)

Shows a window with some kind of error message.

message is the message, in plain text, that should be shown. options is an object controlling the behavior of the error window

options may contain these keys:

  • softReload If this property is present and evaluates to true, a button is shown that executes MistVideo.player.api.load(). If the value is a number, a countdown is added to the button. When the countdown finishes, the button is pressed.

  • reload If this property is present and evaluates to true, a button is shown that executes MistVideo.reload(). If the value is a number, a countdown is added to the button. When the countdown finishes, the button is pressed.

  • nextCombo If this property is present and evaluates to true, a button is shown that executes MistVideo.nextCombo(). If the value is a number, a countdown is added to the button. When the countdown finishes, the button is pressed.

  • ignore If this property is present and evaluates to true, a button is shown that ignores subsequent errors of this type (see below) of error for the lifetime of this meta-player instance. If the value is a number, a countdown is added to the button. When the countdown finishes, the button is pressed.

  • type Is used in combination with the ignore button action to determine whether this error should be displayed or not. If this property is unset or its value is false, it defaults to the contents of the message parameter.

  • polling If this property is present and evaluates to true, a small loading icon is shown, indicating that something is being checked in the background.

  • passive If this property is present and evaluates to true, it will not replace an error window that is already being shown, unless that error is also passive. In that case, the message text will be updated, but the buttons (and their current countdowns values) will not.

Note that the button countdowns are disabled in the developers' skin.

If options is not passed or evaluates to false, it defaults to:

{
softReload: !!((MistVideo.video) && (MistVideo.video.load)),
reload: 10,
nextCombo: !!MistVideo.info
}

clearError()

Hides the current error window if there is one.

metaTrackSubscriptions

metaTrackSubscriptions allows the player to add or remove a certain track as metadata channel. In order to add or remove a track you will need to add the track number and function to the call.

metaTrackSubscriptions.add(trackidx,function)

Will subscribe the player to the given track number and pass any of the metadata message received through the given function.

example:

metaTrackSubscriptions.add(1,console.log)

This would have the player subscribe to track ID 1 and output any received metadata into the console output.

metaTrackSubscriptions.remove(trackidx,function)

Will remove the matching subscription, the player will no longer input the metadata through the given function.

example:

metaTrackSubscriptions.remove(1,console.log)

This would stop any new metadata received through track ID 1 from being output through the console output.