Playback
The Playback module lets you play media streams.
Streams
First you need to create a Stream object. You do this by passing an MRL to the createStream function. All other functions will take the Stream object as their first argument.
Playback Control
Once you have a Stream object, call play to start playing. The functions pause and stop also behave as you would expect them to.
You can get the Stream's PlaybackState by calling the getPlayState function. Alternatively you can connect to the onPlayStateChanged Signal to be notified of changes to the playback state.
[Here we should have some sort of flowchart that shows how the differnt function calls affect the playback state, but that's not done yet.]
Notice: In the future, it should be possible to play multiple Streams simultaneously and our API is structured to reflect that. Right now, due to hardware limitations, only a single Stream may be playing at any given time. Calling play() on a Stream, while another Stream is playing, will stop the already playing Stream.
On Demand Streams vs Live Streams
There are two types of media streams: On Demand, and Live. On Demand Streams are things like video files on a usb stick, a downloaded movie, a reconding, and prety much any other self contained media file. Live streams are things like TV Channels, radio, Live online streaming etc. The functions getPosition, getDuration, and setPosition have different meanings for these two types of streams.
For On Demand Streams, getDuration will return the length of the stream in seconds and getPosition will return the current position also in seconds. Additionally, while the Stream is playing, the onPositionChanged Signal will also fire regularly to inform you of the current playback position.
For Live Streams, both getDuration and getPosition will return zero.
Playback Speed
You can modify the playback speed with the setSpeed function. You can rewind by setting a negative value. Keep in mind that not all Streams support all playback speeds. To find out what speeds are supported you should first call getSupportedSpeeds.
Transformation
By default, a video will be shown fullscreen. You can instead use the setVideoRect function to specify a screen rectangle in which you want the video to appear. If the dimensions of the video and the rectangle don't match, the video will be transformed to match the rectangle. Set the desired Transformation with the setTransformation function. The default Transformation is FIT.
Volume
You control the Stream's volume with the setVolume and setMute functions. The onVolumeChanged Signal will also fire whenever volume or mute change.
Members
CodecType
Enum for the codec types.
Properties:
| Name | Type | Description |
|---|---|---|
| MPEG2V | ||
| H264 | ||
| HEVC | ||
| MPEG2A | ||
| AAC_ADIF | ||
| HEAAC | ||
| HEAACv2 | ||
| AC3 | ||
| EAC3 | ||
| DVB_SUBS | ||
| TELETEXT_SUBS |
onErrorEvent
Signal fired when a Stream enters an error state. The listener will be passed the following arguments:
- stream: The Stream object that produced this Signal.
- error: The triggered error code of the Stream.
onPlaybackEvent
Signal fired when a generic playback event occurs with a Stream. The listener will be passed the following arguments:
- stream: The Stream object that produced this Signal.
- event: The event which caused the signal to fire with the Stream.
onPlayStateChanged
Signal fired when a Stream's playback state changes. The listener will be passed the following arguments:
- stream: The Stream object that produced this Signal.
- state: The Stream's new playback state. Of type PlaybackState.
- data: The info the new state may carry with it. For example, when state is STOPPED, data is a boolean which is true when the state was changed by the end of media event, and false in any other case.
onPositionChanged
Signal fired when a Stream's playback position changes. The listener will be passed the following arguments:
- stream: The Stream object that produced this Signal.
- position: The Stream's new playback position in seconds.
onVolumeChanged
Signal fired when a Stream's volume changes or is muted. The listener will be passed the following arguments:
- stream: The Stream object that produced this Signal.
- volume: The Stream's new volume.
- mute: A boolean signifying if the stream is muted.
PlaybackError
Enum for the error codes the onErrorEvent signal throws.
Properties:
| Name | Type | Description |
|---|---|---|
| OK | No error | |
| UNKNOWN | Undefined error | |
| NOMEM | No memory error | |
| AGAIN | Try again | |
| EOS | EOS reached | |
| PLATFORM | Generic Plaform error | |
| NETWORK | Generic Network error | |
| NETWORK_TIMEOUT | Network timeout error | |
| NETWORK_CONNECT | Network connect error | |
| NETWORK_SEND | Network send error | |
| NETWORK_RECEIVE | Network receive error | |
| NETWORK_ADD_MEMBERSHIP | Network multicast add membership error | |
| NETWORK_DROP_MEMBERSHIP | Network multicast drop membership error | |
| NETWORK_DNS | Network DNS error | |
| NETWORK_SETOPTION | Network set option error | |
| NETWORK_GETOPTION | Network get option error | |
| NETWORK_PEER_SHUTDOWN | Network peer has shutdown connection | |
| HTTP_BASIS | Start of Http error codes | |
| HTTP_BAD_REQUEST | Http error | |
| HTTP_UNAUTHORISED | Http error | |
| HTTP_PAYMENT_REQUIRED | Http error | |
| HTTP_FORBIDDEN | Http error | |
| HTTP_NOT_FOUND | Http error | |
| HTTP_METHOD_NOT_ALLOWED | Http error | |
| HTTP_NOT_ACCEPTABLE | Http error | |
| HTTP_PROXY_AUTHENTICATION_RQUIRED | Http error | |
| HTTP_REQUEST_TIMEOUT | Http error | |
| HTTP_REQUEST_ENTITY_TOO_LARGE | Http error | |
| HTTP_PRECONDITION_FAILED | Http error | |
| HTTP_REQUESTED_RANGE_NOT_SATISFIABLE | Http error | |
| HTTP_REQUESTED_RANGE_EXPECTATION_FAILED | Http error | |
| HTTP_UNAVAILABLE_FOR_LEGAL_REASON | Http error | |
| HTTP_INTERNAL_SERVER | Http error | |
| HTTP_NOT_IMPLEMENTED | Http error | |
| HTTP_BAD_GATEWAY | Http error | |
| HTTP_SERVICE_UNAVAILABLE | Http error | |
| HTTP_GATEWAY_TIMEOUT | Http error | |
| HTTP_VERSION_NOT_SUPPORTED | Http error | |
| STREAM | Generic Stream data error | |
| STREAM_BASIS | Generic Stream data error | |
| STREAM_HLS_KEY_NET | ||
| STREAM_HLS_LIST_NET | ||
| STREAM_HLS_LIST_NET_451 | ||
| STREAM_HLS_CHUNK_NET | ||
| STREAM_HLS_CHUNK_NET_451 | ||
| DRM | Generic DRM error | |
| DRM_NETWORK | Network DRM error (eg fetching license) | |
| DRM_DEVICE | Device DRM error (eg setting license) | |
| METAFILE | Generic Metafile error | |
| FILE | Generic File error | |
| FORMAT_NOT_SUPPORTED | The format is not supported | |
| FILE_CORRUPT | The file is corrupt | |
| FILE_PERMISSION_DENIED | Permission denied | |
| FILE_NO_SPACE | No space left on the device | |
| FILE_NO_ENOENT | No such file or directory | |
| FILE_OPEN | Generic file open error | |
| FILE_WRITE | Generic file write error | |
| FILE_READ | Generic file read error | |
| PLAYLIST | Generic Playlist error | |
| PLAYLIST_UNSUPPORTED | The playlist format is not supported | |
| PLAYLIST_INVALID | The playlist file contents are invalid | |
| SUBTITLES | Generic Subtitles error | |
| SUBTITLES_UNSUPPORTED | The subtitles format is not supported | |
| SUBTITLES_INVALID | The subtitles file contents are invalid | |
| COPYRIGHT_PROTECTION | Copyright protection error (HDCP/Macrovision etc...) |
PlaybackEvent
Enum for the playback events the onPlaybackEvent signal throws.
Properties:
| Name | Type | Description |
|---|---|---|
| NO_EVENT | ||
| MEDIA_DESCRIPTION_CHANGED | ||
| MEDIA_READ_STALLED | ||
| END_OF_MEDIA | ||
| ERROR_MEDIA_FORMAT_NOT_SUPPORTED | ||
| ERROR_INTERNAL_ERROR | ||
| ERROR_MEDIA_READ_FAILED | ||
| ERROR_MEDIA_OPEN_FAILED | ||
| EXTERNAL_ACTION | ||
| ERROR_MEDIA_PROTOCOL_NOT_SUPPORTED | ||
| ERROR_MEDIA_PERMISSION_DENIED | ||
| HLS_KEY_NET_ERROR | ||
| HLS_LIST_NET_ERROR | ||
| HLS_LIST_NET_ERROR451 | ||
| HLS_CHUNK_NET_ERROR | ||
| HLS_CHUNK_NET_ERROR451 | ||
| BUFFERING_START | ||
| BUFFERING_END | ||
| TIMESHIFT_STATUS_STARTED | ||
| TIMESHIFT_STATUS_ENDED | ||
| TIMESHIFT_STATUS_FULL | ||
| TIMESHIFT_STATUS_POSSIBLE | ||
| TIMESHIFT_STATUS_NOT_POSSIBLE | ||
| TIMESHIFT_EOS | ||
| TIMESHIFT_BOS | ||
| PLAYBACK_STATE_CHANGE |
PlaybackState
Enum for the different states a Stream may go through.
Properties:
| Name | Type | Description |
|---|---|---|
| PLAYING | Stream is playing | |
| PAUSED | Stream is paused | |
| STOPPED | Stream is stopped | |
| BUFFERING | Stream is buffering |
TimeshiftBufferingPolicy
Enum for the timeshift buffering policy. The timeshift buffering policy specification is for declaring how to handle the case where timeshift is paused for so long that the buffer has reached its maximum size.
Properties:
| Name | Type | Description |
|---|---|---|
| NON_OVERWRITE | When timeshift buffer fills up and the video is still paused, any new data will be discarted. | |
| OVERWRITE | When timeshift buffer fills up and the video is still paused, the oldest data in the buffer will be overwritten by the new data. |
Transformation
Enum for video transformations.
Properties:
| Name | Type | Description |
|---|---|---|
| FIT | Fit the entire video into its rectangle, leaving black bars. | |
| FILL | Fill the entire rectangle with the video, cutting out parts of the video. | |
| STRETCH | Fill the entire rectangle with the video, distorting the video to fit. |
Methods
availableAudioDescriptions(stream)
Get the available audio descriptions for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - languages: An array with the supported audio description languages (ISO 639-2). |
createStream(mrl)
Creates a new Stream object. Each Stream object is uniquely identified by it's MRL.
Parameters:
| Name | Type | Description |
|---|---|---|
mrl | MRL | The new Stream's MRL. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - stream: The Stream object that has been created. |
enableClosedCaption(stream, enable, digital_cc)
Enable/disable closed caption for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
enable | Boolean | The desired value for closed caption visibility; true for visible, false for non-visible. |
digital_cc | Boolean | True if CEA708 captions are to be decoded, false for CEA608 |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
enableSubtitles(stream, enable)
Enable/disable subtitles for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
enable | Boolean | The desired value for subtitles visibility; true for visible, false for non-visible. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
getAudioLanguage(stream)
Get the audio language for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - language: The audio language of the currently playing stream. |
getAudioTracksInfo(stream)
Get audio tracks information for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - info: An array of objects with information about the stream's audio tracks. |
| Each object in the array corresponds to a different audio track. |
getDuration(stream)
Get the Stream's duration. This function will always return 0 for Live Streams.
Notice: The stream must have started playing for the duration to become available.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - duration: The Stream's duration in seconds. |
getMute(stream)
Get the audio's mute property.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - mute: The Stream's audio mute property. |
getPlayState(stream)
Gets the current Playback State.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - state: A value of type PlaybackState. |
getPosition(stream)
Get the current playback position in seconds. Live streams will always return 0 unless timeshift is enabled. See the timeshift module for details.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - position: The Stream's position in seconds. |
getSpeed(stream)
Get the playback speed.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - speed: The current speed. |
getSubtitleLanguage(stream)
Get the subtitle language for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - language: The subtitle language of the currently playing stream. |
getSubtitleTracksInfo(stream)
Get subtitle tracks information for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - info: An array of objects with information about the stream's subtitle tracks. |
| Each object in the array corresponds to a different subtitle track. |
getSupportedSpeeds(stream)
Gets the supported playback speeds. If the stream only supports discrete playbak speeds (i.e. 2x, 4x, 16x, etc.), the function will return an array of these values (like [2, 4, 16] ). If the stream supports fractional playback speeds, the function will return an Array of ranges. Each range will be an Array of two numbers: the lower limit and the upper limit. (like [[-16,-0.5], [0.5, 16]] )
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - speeds: An Array of speeds. |
getTeletextTracksInfo(stream)
Get teletext tracks information for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - info: An array of objects with information about the stream's teletext tracks. |
| Each object in the array corresponds to a different teletext track. |
getTimeshiftInfo(stream)
Get timeshift related information. Not applicable for server based timeshift.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - info: A TimeshiftInfo object containing the timeshift related information. |
getTransformation(stream)
Get the Video Transformation.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - transformation: The current video transformation. |
getVideoRect(stream)
Get the Video Rectangle.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - rect: The current video rectangle. |
getVideoTracksInfo(stream)
Get video tracks information for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - info: An array of objects with information about the stream's video tracks. |
| Each object in the array corresponds to a different video track. |
getVolume(stream)
Get the audio volume.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - volume: The Stream's audio volume. Takes values from 0 to 100. |
injectTeletextKey(stream, key)
Inject a key to the teletext renderer.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
key | Number | The desired key to inject. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
isAudioDescriptionEnabled(stream)
Get whether the audio description for the visually impaired is enabled.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - enabled: True when audio description is enabled, false otherwise. |
isTeletextAvailable(stream)
Check whether teletext is available in the current video stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - available: True when teletext is available, false otherwise. |
pause(stream)
Pauses playback of a Stream. If the Stream is a Live Stream this activates timeshift. See the timeshift module for more details.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
play(stream, initial_position)
Starts or resumes playback of a Stream. You can specify the initial position to start the playback if you like. Default value for this, if none specified, will be set to 0 (start playback from beginning).
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
initial_position | Number | The stream position where we want to start playing from (secs). |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
seekToLive(stream)
Exit timeshift mode. Skip all the timeshifted data and get the most recent content.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setAudioDescriptionVolume(stream, volume)
Sets the audio description volume.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
volume | Number | The desired value for audio description. The value must range between 0 and 100 (inclusive). |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setAudioLanguage(stream, language, codecType)
Set the audio language for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
language | String | The desired audio language for the stream. |
codecType | module:Platform.Playback.CodecType | The codec type of the desired audio language. Values of getAudioTracksInfo for the codec can be used directly. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setAudioTrack(stream, track)
Set the audio track for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
track | Number | The desired audio track number for the stream. Track number is got from getAudioTracksInfo |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setClosedCaptionService(stream, service_number)
Set the closed caption service number for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
service_number | Number | The desired closed caption service number, should be 1, 2, 3 or 4. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setMute(stream, mute)
Set the audio's mute property.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
mute | Boolean | If `true the audio will be muted. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setPosition(stream, position)
Seeks to a specified position in the Stream. Has no effect for Live Streams unless timeshift is enabled. See the timeshift module for details. This function takes effect only in already active streams. In order to start playback from a position, please refer to play.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
position | Number | The position in seconds. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setPreferredAudioLanguage(stream, lang)
Sets the preferred audio language for the next playback. In case the stream does not include an audio track with the preferred language, the first audio track is used for playback. In case both setPreferredAudioLanguage and setPreferredAudioTrackIndex are set, the language setting has a priority over the track index setting. The setting is effective only for the next playback. The method must be called after the previous playback is finished and before the next one is started. Calling it during a playback will not have any effect.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
lang | String | The preferred audio language defined as a 3-digit code (ISO 639-2). The language must be in sync with the one that appears in the stream information. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setPreferredAudioTrackIndex(stream, idx)
Sets the preferred audio track index for the next playback. In case the stream does not include an audio track with the preferred index, the first audio track is used for playback. In case both setPreferredAudioLanguage and setPreferredAudioTrackIndex are set, the language setting has a priority over the track index setting. The setting is effective only for the next playback. The method must be called after the previous playback is finished and before the next one is started. Calling it during a playback will not have any effect.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
idx | Number | The index of the preferred audio track. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setPreferredSubtitlesLanguage(stream, lang)
Sets the preferred subtitle language for the next playback. In case both setPreferredSubtitlesLanguage and setPreferredSubtitleTrackIndex are set, the language setting has a priority over the track index setting. The setting is effective only for the next playback. The method must be called after the previous playback is finished and before the next one is started. Calling it during a playback will not have any effect.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
lang | String | The preferred subtitle language defined as a 3-digit code (ISO 639-2). The language must be in sync with the one that appears in the stream information. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setPreferredSubtitleTrackIndex(stream, idx)
Sets the preferred subtitle track index for the next playback. In case both setPreferredSubtitlesLanguage and setPreferredSubtitleTrackIndex are set, the language setting has a priority over the track index setting. The setting is effective only for the next playback. The method must be called after the previous playback is finished and before the next one is started. Calling it during a playback will not have any effect.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
idx | Number | The index of the preferred subtitle track. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setSpeed(speed, stream)
Sets the playback speed. calling setSpeed(0) is equivalent with pause(). Calling setSpeed(1) is equivalent with play().
Parameters:
| Name | Type | Description |
|---|---|---|
speed | Number | The desired speed. |
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setSubtitleLanguage(stream, language)
Set the subtitle language for the currently playing stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
language | String | The desired subtitle language for the stream. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setTimeshiftOptions(stream, options)
Set timeshift related options.
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
stream | Stream | The Stream object. | ||||||||||||
options | Object | The desired timeshift options we wish to set. In case any of the properties are undefined, the underlying player will use default values. Properties:
|
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setTrack(stream, track_index)
Set the track to track_index for the provided stream. Any track_index is valid as long as a track with the same index exists in the desired stream. This function can be used to activate any type of track (video, audio, etc.).
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
track_index | Number | The desired track to enable for the provided stream. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setTransformation(stream, transformation)
Set the desired video transformation.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
transformation | Transformation | The desired video transformation. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setVideoRect(stream, x, y, w, h)
Specify the browser coordinates (in pixels) where the video should be displayed.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
x | Number | The Video's X coordinate. |
y | Number | The Video's Y coordinate. |
w | Number | The Video's width. |
h | Number | The Video's height. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
setVolume(stream, volume)
Set the audio Volume.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
volume | Number | The desired volume. Takes values from 0 to 100. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
showTeletext(show)
Enable/disable teletext rendering.
Parameters:
| Name | Type | Description |
|---|---|---|
show | Boolean | True to show teletext, false to hide it. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
startAudioDescription(stream)
Starts the audio description for the visually impaired. Whenever the currently set audio track supports audio description, it will be played along with the stream audio.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
stop(stream)
Stops playback of a Stream.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
stopAudioDescription(stream)
Stops the audio description for the visually impaired.
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
toggleTeletextMixMode(stream)
Toggle Teletext mix-mode (transparent Teletext background)
Parameters:
| Name | Type | Description |
|---|---|---|
stream | Stream | The Stream object. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
Type Definitions
Stream
Notice: This is an internal object. Do not depend on its implementation details remaining constant between releases of the API.
You create a Stream object by passing an MRL to the createStream function. You then pass it as the first argument of all the other functions.
Currently, Stream is a simple integer specifying the id of the Stream.
TimeshiftInfo
A placeholder object for the timeshift related information.
Properties:
| Name | Type | Description |
|---|---|---|
cachedBytes | Number | The number of bytes currently cached in the timeshift buffer. |
bufferSize | Number | The size of the timeshift buffer in bytes. |
playPosition | Number | The play position in the timeshift buffer in bytes. |
cachedPercentage | Number | The percentage of cached bytes relative to the size of timeshift buffer. |
playedPercentage | Number | The percentage of played bytes relative to the size of timeshift buffer. |