• Quick Start
  • Booting
  • Platform
  • Portals
  • References
    • API Reference TOI3
    • IIP Reference
  • Resources
ARRIS Enterprises, Inc. Confidential Information

ToiMediaPlayer

Class Summary

Extends:
  • ToiMediaPlayerBase
See also:
  • ToiMediaPlayerBase
  • ToiMediaService

The ToiMediaPlayer interface is the access point for an application to its private media player instance. Access to this interface is acquired through the ToiMediaService#createPlayerInstance function. It is possible to create multiple private media player instances. Each application gets its own private instance of this interface for each of its media player instances.

  • Methods

Method Summary

activateComponent ( mediaComponent )

This function selects a media component to be used. The player state is not affected. For example, choosing a different audio language.

close ( ) Closes the current session by stopping playback and disconnecting from the media source.
deactivateComponent ( mediaType )

This function deactivates a media component type.

discardTimeshiftBuffer ( )

Discards the timeshift buffer and resumes live stream playback, if not already playing live. This disables further timeshift operations. If this function returns successfully, the timeshift state has changed to TIMESHIFT_STATE_INACTIVE.

open ( url ) Starts a new stream session by connecting to the media source. Player will transition to ToiMediaPlayerBase.STATE_PAUSED when connected.
play ( pace ) Controls playback of the stream. Pace argument decides if it plays, pauses, or enters trickplay.
playFromPosition ( position , pace ) Moves playback position within the current stream and resumes playback.
quickPlay ( url ) A combination of ToiMediaPlayer#close, ToiMediaPlayer#open and ToiMediaPlayer#play.
quickPlayFromPosition ( url , position ) A combination of ToiMediaPlayer#close, ToiMediaPlayer#open and ToiMediaPlayer#playFromPosition.
redirectTimeshiftBuffering ( url )

Redirects the timeshift buffering to a new URL. The use case for this function is when the buffering URL need to be set or changed while playing from the timeshift buffer. If the timeshift state is TIMESHIFT_STATE_BUFFERING the buffering will stop on the current URL and then continue on the new URL. If the timeshift state is TIMESHIFT_STATE_STOPPED the buffering will just start on the new URL. The timeshift playback will continue unaffected by the redirection. If the redirection for some reason fails the player will go to live playback on the new URL. Playing from POSITION_LIVE after the redirection will also start live playback on the new URL.

Note that calling this function with high frequency will result in a fragmented buffer containing a lot of chopped pieces of content and KreaTV can not guarantee playback quality of such content. It is therefore not recommended to use this function for e.g. end user zapping.

Redirecting the timeshift buffering to a non-live media source that does not support timeshift operations will result in a timeshift state transition to TIMESHIFT_STATE_BUFFERING_FAILED with reason ToiMediaService.REASON_TIMESHIFT_BUFFER_REDIRECTED. The playback will continue to the end of the buffer.

setAudioChannelMode ( streamId , channelMode )

This function sets the audio channel mode for a given stream identifier. For the active stream the mode will be set instantly.

setParameters ( parameters ) Sets the values of multiple media player parameters at once.
startTimeshiftBuffering ( maxBufferLength )

Starts background buffering of the currently viewed stream and therefore enables timeshift operations. The media player will continue to display the live stream until either pause or rewind is performed. The timeshift buffering is stopped either by an explicit call to ToiMediaPlayer#stopTimeshiftBuffering or when the buffer is full. Timeshift operations are disabled by calling ToiMediaPlayer#discardTimeshiftBuffer. If this function returns successfully, the timeshift state has changed to TIMESHIFT_STATE_BUFFERING. The behavior and preconditions for calling this function is different depending on the current timeshift recording policy configuration ToiInformationService.CFG_MEDIA_TIMESHIFT_RECORDINGPOLICY. The normal recording policy is more strict and only allows one sequence of calls, start->stop->discard and closing the media session will automatically discard the buffer. The continuous recording policy is more flexible and allows subsequent calls, start->stop->...->start->stop->discard. The continuous recording policy also keeps the timeshift buffer without discarding when closing the media session, making it possible for the timeshift buffer to follow a channel change.

stopTimeshiftBuffering ( )

Stops the timeshift buffering but preserves the content in the buffer until the function ToiMediaPlayer#discardTimeshiftBuffer is called. The player will continue to play from the current media source. If this function returns successfully, the timeshift state has changed to TIMESHIFT_STATE_STOPPED.

unsetParameters ( names ) Removes several media player parameters at once.

Inherited Methods

addEventListener ( type , listener )

This method registers an event listener for a specific event. Multiple listeners can be added for the same event. Events are broadcast to all registered listeners.

getAudioStreamInfo ( mediaComponent )  → streamInfo

Returns information about a specified audio stream in the current media stream multiplex in the form of an audio stream info structure.

getCapabilities ( )  → capabilityMask

Returns the capabilities present for the current session.

getError ( )  → error

Returns the last error. This is typically called when state is changed to ToiMediaPlayerBase.STATE_FAILED. The result is undefined if no error has occurred.

getMediaBufferInfo ( )  → info

Returns information about the current status of the media buffer.

getParameters ( names )  → Array.<ToiMediaSession.ToiParameterInfo>

Get the values of several parameters.

getPositionInfo ( )  → positionInfo

Returns pace and position information for the current media session.

getPresentationInfo ( )  → info

Returns the presentation information about current video and audio lock status. Audio locked means audio decoder is started, sample rate is locked and no sync loss. Video locked means video decoder is started and no sync loss.

getSessionId ( )  → id

Returns the session identifier. This identifier can be used to open a session object with ToiMediaService#openSession.

getState ( )  → state

Returns the current state of the media player instance.

getStreamInfo ( )  → streamInfo

Returns information about the current stream in form of a stream info structure. The lists of audio and video streams provided as parts of this information can be used for further exploration using the ToiMediaPlayerBase#getAudioStreamInfo and ToiMediaPlayerBase#getVideoStreamInfo functions, respectively.

getSubtitleStreamInfo ( mediaComponent )  → streamInfo

Returns information about a specified subtitle stream in the current media stream multiplex in the form of a subtitle stream info structure.

getTeletextStreamInfo ( mediaComponent )  → streamInfo

Returns information about a specified teletext stream in the current media stream multiplex in the form of a teletext stream info structure.

getTimeshiftError ( )  → timeshiftError

Returns the last timeshift error. This is typically called after a state change to ToiMediaPlayerBase.TIMESHIFT_STATE_BUFFERING_FAILED. The result is undefined if no error has occurred.

getTimeshiftInfo ( )  → timeshiftInfo

Retrieve information about the current timeshift operation.

getUrl ( )  → url

Returns the URL for the media stream.

getVideoStreamInfo ( mediaComponent )  → streamInfo

Returns information about a specified video stream in the current media stream multiplex in the form of a video stream info structure.

isTimeshiftPlayback ( )  → timeshiftPlayback

Returns true if the player is playing from the timeshift buffer.

releaseInstance ( )

This function releases the resources used by this instance. When this function returns all observers has also been released.

removeEventListener ( type , listener )

This method removes an event listener for a specific event.

subscribeParameters ( eventListener , names )

This function makes the application subscribe to updates of the given list of parameters. The first time an application subscribes to a specific parameter there will be an immediate ToiMediaPlayerParameterChangedEvent notification if the parameter already has a value.

unsubscribeParameters ( eventListener , names )

This function undoes the effect of a previous call to ToiMediaPlayerBase#subscribeParameters. Any parameters that has not been subscribed to will simply be ignored.

Methods

activateComponent ( mediaComponent )

This function selects a media component to be used. The player state is not affected. For example, choosing a different audio language.

Parameters:

Name Type Description
mediaComponent ToiMediaPlayerBase.ToiComponentEntry

The media component entry to be activated.

Throws:

ToiSessionViolationException

If the player is in STATE_IDLE a session violation exception is raised.

ToiInvalidArgumentException

If the component argument does not identify a valid component, an invalid argument exception is raised.

ToiUnavailableException

ToiUnavailableException is raised if the player is temporarily unavailable due to platform resource management.

addEventListener ( type , listener )

This method registers an event listener for a specific event. Multiple listeners can be added for the same event. Events are broadcast to all registered listeners.

Inherited From:

  • ToiEventTarget#addEventListener

Parameters:

Name Type Description
type number

The event type of the event to subscribe to.

listener ToiEventListener

The JavaScript function that will receive events.

Throws:

ToiInvalidArgumentException Raised if the event type is not supported by this object or if the listener is not a valid JavaScript function. This exception is also raised if the application calls addEventListener with the same combination of type and listener twice.

close ( )

This function ends the current session by stopping any playback and disconnecting from the media source. For example, if the source is a video server it ends the server session and disconnects, or if the source is a multicast channel it leaves that multicast group. If there is an ongoing timeshift on the session it will be stopped or discarded depending on the current timeshift recording configuration ToiInformationService.CFG_MEDIA_TIMESHIFT_RECORDINGPOLICY. If this function returns successfully, the player state will change to STATE_IDLE. If an exception is raised, the player state is unaffected.

See also:

  • ToiMediaPlayer#open
  • ToiMediaPlayerBase.ToiState

Throws:

ToiSessionViolationException

If the player is in idle state a session violation exception is raised.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

deactivateComponent ( mediaType )

This function deactivates a media component type.

Parameters:

Name Type Description
mediaType ToiMediaPlayerBase.ToiComponentType

The media component type to be deactivated.

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiInvalidArgumentException

Raised if the component argument does not identify a valid component.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

discardTimeshiftBuffer ( )

Discards the timeshift buffer and resumes live stream playback, if not already playing live. This disables further timeshift operations. If this function returns successfully, the timeshift state has changed to TIMESHIFT_STATE_INACTIVE.

See also:

  • ToiMediaPlayer#startTimeshiftBuffering
  • ToiMediaPlayer#stopTimeshiftBuffering
  • ToiMediaPlayer#redirectTimeshiftBuffering

Throws:

ToiSessionViolationException

If the player is in STATE_IDLE a session violation exception is raised.

ToiInvalidPreconditionException

If the timeshift state is not TIMESHIFT_STATE_STOPPED or TIMESHIFT_STATE_BUFFERING_FAILED an invalid precondition exception is raised.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

getAudioStreamInfo ( mediaComponent )  → streamInfo

Returns information about a specified audio stream in the current media stream multiplex in the form of an audio stream info structure.

Inherited From:

  • ToiMediaPlayerBase#getAudioStreamInfo

Parameters:

Name Type Description
mediaComponent ToiMediaPlayerBase.ToiComponentEntry

The media component entry for which the stream info has to be retrieved.

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiInvalidArgumentException

If the mediaComponent given as argument does not identify an audio stream in the current stream multiplex, an invalid argument exception is raised.

ToiUnavailableException

ToiUnavailableException is raised if the player is temporarily unavailable due to platform resource management.

Returns:

Information about the specified audio stream.

Type: ToiMediaPlayerBase.ToiAudioStreamInfo
getCapabilities ( )  → capabilityMask

Returns the capabilities present for the current session.

Inherited From:

  • ToiMediaPlayerBase#getCapabilities

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiUnavailableException

ToiUnavailableException is raised if the player is temporarily unavailable due to platform resource management.

Returns:

A bit mask describing the capabilities of the current session. The mask can include the following capabilities:

  • Bit 0: ToiMediaPlayerBase.CAPABILITY_PAUSE
  • Bit 1: ToiMediaPlayerBase.CAPABILITY_REWIND
  • Bit 2: ToiMediaPlayerBase.CAPABILITY_FASTFORWARD
  • Bit 3: ToiMediaPlayerBase.CAPABILITY_GETPOSITION
  • Bit 4: ToiMediaPlayerBase.CAPABILITY_SETPOSITION
  • Bit 5: ToiMediaPlayerBase.CAPABILITY_FREEZE
  • Bit 6: ToiMediaPlayerBase.CAPABILITY_TIMESHIFT
  • Bit 7: ToiMediaPlayerBase.CAPABILITY_MEDIA_BUFFER
Type: number
getError ( )  → error

Returns the last error. This is typically called when state is changed to ToiMediaPlayerBase.STATE_FAILED. The result is undefined if no error has occurred.

Inherited From:

  • ToiMediaPlayerBase#getError

Returns:

The error

Type: ToiMediaPlayerBase.ToiError
getMediaBufferInfo ( )  → info

Returns information about the current status of the media buffer.

Inherited From:

  • ToiMediaPlayerBase#getMediaBufferInfo

See also:

  • ToiMediaPlayerMediaBufferStatusChangedEvent

Throws:

ToiSessionViolationException

Raised if the player is in ToiMediaPlayerBase.STATE_IDLE.

ToiOperationNotSupportedException

Raised if the session lacks the capability ToiMediaPlayerBase.CAPABILITY_MEDIA_BUFFER to get media buffer info.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

Returns:

The current media buffer information.

Type: ToiMediaPlayerBase.ToiMediaBufferInfo
getParameters ( names )  → Array.<ToiMediaSession.ToiParameterInfo>

Get the values of several parameters.

Inherited From:

  • ToiMediaPlayerBase#getParameters

See also:

  • ToiMediaPlayer#setParameters
  • ToiMediaPlayer#unsetParameters
  • ToiMediaPlayerBase#subscribeParameters

Parameters:

Name Type Description
names Array.<ToiMediaSession.ToiParameterName> (Or a single ToiMediaSession.ToiParameterName.)

A list of parameter names. A single element can be passed directly and does not need to be passed in an array.

Throws:

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

Returns:

A list of the returned parameters. If a parameter does not exist (is not set), the status of the corresponding parameter is set to ToiMediaSession.STATUS_NO_PARAMETER.

Type: Array.<ToiMediaSession.ToiParameterInfo>
getPositionInfo ( )  → positionInfo

Returns pace and position information for the current media session.

Inherited From:

  • ToiMediaPlayerBase#getPositionInfo

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiOperationNotSupportedException

If the session lacks the capability to get position, the operation not supported exception is raised.

ToiUnavailableException

ToiUnavailableException is raised if the player is temporarily unavailable due to platform resource management.

Returns:

Position and pace information for the current media session.

Type: ToiMediaPlayerBase.ToiPositionInfo
getPresentationInfo ( )  → info

Returns the presentation information about current video and audio lock status. Audio locked means audio decoder is started, sample rate is locked and no sync loss. Video locked means video decoder is started and no sync loss.

Inherited From:

  • ToiMediaPlayerBase#getPresentationInfo

Technical Preview:

This method is a TECHNICAL PREVIEW, it may change.

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiUnavailableException

ToiUnavailableException is raised if the player is temporarily unavailable due to platform resource management.

Returns:

Information about the current lock status of video and audio.

Type: ToiMediaPlayerBase.ToiPresentationInfo
getSessionId ( )  → id

Returns the session identifier. This identifier can be used to open a session object with ToiMediaService#openSession.

Inherited From:

  • ToiMediaPlayerBase#getSessionId

See also:

  • ToiMediaService#openSession

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

Returns:

The session identifier.

Type: ToiMediaSession.ToiSessionId
getState ( )  → state

Returns the current state of the media player instance.

Inherited From:

  • ToiMediaPlayerBase#getState

Returns:

The current player state.

Type: ToiMediaPlayerBase.ToiState
getStreamInfo ( )  → streamInfo

Returns information about the current stream in form of a stream info structure. The lists of audio and video streams provided as parts of this information can be used for further exploration using the ToiMediaPlayerBase#getAudioStreamInfo and ToiMediaPlayerBase#getVideoStreamInfo functions, respectively.

Inherited From:

  • ToiMediaPlayerBase#getStreamInfo

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiUnavailableException

ToiUnavailableException is raised if the player is temporarily unavailable due to platform resource management.

Returns:

Information about the current stream.

Type: ToiMediaPlayerBase.ToiStreamInfo
getSubtitleStreamInfo ( mediaComponent )  → streamInfo

Returns information about a specified subtitle stream in the current media stream multiplex in the form of a subtitle stream info structure.

Inherited From:

  • ToiMediaPlayerBase#getSubtitleStreamInfo

Parameters:

Name Type Description
mediaComponent ToiMediaPlayerBase.ToiComponentEntry

The media component entry for which the stream info has to be retrieved.

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiInvalidArgumentException

If the streamId given as argument does not identify a subtitle stream in the current stream multiplex, an invalid argument exception is raised.

ToiUnavailableException

ToiUnavailableException is raised if the player is temporarily unavailable due to platform resource management.

Returns:

Information about the specified subtitle stream.

Type: ToiMediaPlayerBase.ToiSubtitleStreamInfo
getTeletextStreamInfo ( mediaComponent )  → streamInfo

Returns information about a specified teletext stream in the current media stream multiplex in the form of a teletext stream info structure.

Inherited From:

  • ToiMediaPlayerBase#getTeletextStreamInfo

Parameters:

Name Type Description
mediaComponent ToiMediaPlayerBase.ToiComponentEntry

The media component entry for which the stream info has to be retrieved.

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiInvalidArgumentException

If the mediaComponent given as argument does not identify a teletext stream in the current stream multiplex, an invalid argument exception is raised.

ToiUnavailableException

ToiUnavailableException is raised if the player is temporarily unavailable due to platform resource management.

Returns:

Information about the specified teletext stream.

Type: ToiMediaPlayerBase.ToiTeletextStreamInfo
getTimeshiftError ( )  → timeshiftError

Returns the last timeshift error. This is typically called after a state change to ToiMediaPlayerBase.TIMESHIFT_STATE_BUFFERING_FAILED. The result is undefined if no error has occurred.

Inherited From:

  • ToiMediaPlayerBase#getTimeshiftError

Returns:

The error.

Type: ToiMediaPlayerBase.ToiError
getTimeshiftInfo ( )  → timeshiftInfo

Retrieve information about the current timeshift operation.

Inherited From:

  • ToiMediaPlayerBase#getTimeshiftInfo

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

Returns:

Information about the current timeshift operation.

Type: ToiMediaPlayerBase.ToiTimeshiftInfo
getUrl ( )  → url

Returns the URL for the media stream.

Inherited From:

  • ToiMediaPlayerBase#getUrl

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

Returns:

The URL for the media stream.

Type: string
getVideoStreamInfo ( mediaComponent )  → streamInfo

Returns information about a specified video stream in the current media stream multiplex in the form of a video stream info structure.

Inherited From:

  • ToiMediaPlayerBase#getVideoStreamInfo

Parameters:

Name Type Description
mediaComponent ToiMediaPlayerBase.ToiComponentEntry

The media component entry for which the stream info has to be retrieved.

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiInvalidArgumentException

If the mediaComponent given as argument does not identify a video stream in the current stream multiplex, an invalid argument exception is raised.

ToiUnavailableException

ToiUnavailableException is raised if the player is temporarily unavailable due to platform resource management.

Returns:

Information about the specified video stream.

Type: ToiMediaPlayerBase.ToiVideoStreamInfo
isTimeshiftPlayback ( )  → timeshiftPlayback

Returns true if the player is playing from the timeshift buffer.

Inherited From:

  • ToiMediaPlayerBase#isTimeshiftPlayback

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

Returns:

True if the player is playing from the timeshift buffer, otherwise false.

Type: boolean
open ( url )

This function starts a new stream session by trying to establish a connection to a media source. If this function returns successfully, the player state will change to STATE_CONNECTING. If an exception is raised, the player state is unaffected.

Depending on the success of the connection attempt to the media source, the player will make a second state transition to either ToiMediaPlayerBase.STATE_PAUSED or ToiMediaPlayerBase.STATE_FAILED, on success and failure, respectively. In any respect, the application will be notified with the event ToiMediaPlayerStateChangedEvent.

See also:

  • ToiMediaPlayer#close
  • ToiMediaPlayerBase.ToiState

Parameters:

Name Type Description
url string

The URL identifying the media source. The URL string may contain additional parameter information in accordance to the extended URL format.

Throws:

ToiSessionViolationException

If the player is not in idle state at the time of the call to ToiMediaPlayer#open, a session violation exception is raised. OR When query parameter "SessionMode=AttachOnly" is specified in the URL, if no matching session is found with the specified URL in running state (ToiMediaSession.ToiState.STATE_RUNNING), a session violation exception is raised.

ToiInvalidArgumentException

If the URL given as argument does not follow the extended URL format, an invalid argument exception is raised.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

play ( pace )

This function controls playback of the stream. If this function returns successfully, the player state will change to one of four states: ToiMediaPlayerBase.STATE_PLAYING, ToiMediaPlayerBase.STATE_PAUSED, ToiMediaPlayerBase.STATE_FASTFORWARDING, and ToiMediaPlayerBase.STATE_REWINDING. Different values pace result one of these different states with the corresponding effect. In the case of pausing, it keeps the session alive, i.e. it remains connected to video servers and joined in multicast groups. If an exception is raised, the player state is unaffected.

See also:

  • ToiMediaPlayer#open
  • ToiMediaPlayerBase.ToiState

Parameters:

Name Type Description
pace number

The pace at which the position will change, given as a multiplier of normal playback times 1000. Zero will pause the stream. 1000 is normal speed (playing). Values above 1000 will result in fast forward, and below -1000 will result in rewind. This are desired paces, the actual implementation may not set the desired speed, but the different states will change according to this description.

Throws:

ToiSessionViolationException

Raised if the player does not have an active session and will not have one soon (due to a recent call to Open) either.

ToiOperationNotSupportedException

If the player is in a state is which this operation is not supported, an operation not supported exception is raised. This is the case when in ToiMediaPlayerBase.STATE_FAILED, for example. What is supported in which state may in other cases vary depending on which media source is used.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

playFromPosition ( position , pace )

This function moves the playback position of the current stream and resumes playback at the new position with the desired pace. Streams without a well defined notion of beginning and end, like multicast channels, generally do not support this operation, unless timeshift has been enabled. A position value greater than the length of the stream will be clamped.

If this function returns successfully, the player state will change to one of four states: STATE_PLAYING, STATE_PAUSED, STATE_FASTFORWARDING, and STATE_REWINDING. Different values of pace results in the different states. In the case of pausing, it keeps the session alive, i.e. it remains connected to the video server or the joined in multicast group. If an exception is raised, the player state is unaffected.

Parameters:

Name Type Description
position number

The position, specified as the number of milliseconds from the beginning of the stream, to which the playback position is to be moved. The seekable range of the stream can be obtained by calling the ToiMediaPlayer#getPositionInfo function.

When playing from the timeshift buffer, the constant ToiMediaPlayerBase.POSITION_LIVE can be used to stop buffer playback and start playback of the live stream.

pace number

The pace at which the position will change, given as a multiplier of normal playback times 1000. Zero will pause the stream. 1000 is normal speed (playing). Values above 1000 will result in fast forward, and below -1000 will result in rewind. This are desired paces, the actual implementation may not set the desired speed, but the different states will change according to this description.

Throws:

ToiSessionViolationException

Raised if the player does not have an active session and will not have one soon (due to a recent call to Open) either .

ToiOperationNotSupportedException

If the player is in a state is which this operation is not supported, an operation not supported exception is raised. This is the case when in ToiMediaPlayerBase.STATE_FAILED, for example. What is supported in which state may in other cases vary depending on which media source is used. The client may investigate this in advance by checking capabilities with ToiMediaPlayer#getCapabilities.

ToiInvalidArgumentException

Raised if the position is negative.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

quickPlay ( url )

This function closes any existing playback session and starts playback in a new session. It is the combination of ToiMediaPlayer#close, ToiMediaPlayer#open and ToiMediaPlayer#play. If there is an ongoing timeshift on the current session, it will be stopped or discarded depending on the current timeshift recording configuration ToiInformationService.CFG_MEDIA_TIMESHIFT_RECORDINGPOLICY. If this function returns successfully, the player state will change to ToiMediaPlayerBase.STATE_CONNECTING. If an exception is raised, the player state is unaffected.

The player will make a second state transition depending on the result of connecting to new media source. If the player successfully connects to the source and starts playback, the player state will change to ToiMediaPlayerBase.STATE_PLAYING. If not, the state will change to ToiMediaPlayerBase.STATE_FAILED. In any respect, the application will be notified of the state transitio with event ToiMediaPlayerStateChangedEvent. In ToiMediaPlayerBase.STATE_FAILED, ToiMediaPlayer#close or ToiMediaPlayer#quickPlay can be called to reset the player or start new playback, respectively.

See also:

  • ToiMediaPlayer#open
  • ToiMediaPlayer#close
  • ToiMediaPlayer#play
  • ToiMediaPlayerBase.ToiState
  • ToiInformationService.CFG_MEDIA_TIMESHIFT_RECORDINGPOLICY

Parameters:

Name Type Description
url string

The URL identifying the media source. The URL string may contain additional parameter information in accordance to the extended URL format.

Throws:

ToiSessionViolationException

Raised if no matching session is found with the specified URL in running state (ToiMediaSession.ToiState.STATE_RUNNING) when query parameter "SessionMode=AttachOnly" is specified in the URL.

ToiInvalidArgumentException

Raised if the URL given as argument does not follow the extended URL format.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

quickPlayFromPosition ( url , position )

This function is same as ToiMediaPlayer#quickPlay, except that it starts playback in a new session from a specified position. Streams without a well defined notion of beginning and end, like multicast channels, generally do not support this operation, and result in state ToiMediaPlayerBase.STATE_FAILED.

See also:

  • ToiMediaPlayer#open
  • ToiMediaPlayer#close
  • ToiMediaPlayer#playFromPosition
  • ToiMediaPlayer#quickPlay
  • ToiMediaPlayerBase.ToiState

Parameters:

Name Type Description
url string

The URL identifying the media source. The URL string may contain additional parameter information in accordance to the extended URL format.

position number

The position, specified as the number of milliseconds from the beginning of the stream.

Throws:

ToiSessionViolationException

Raised if no matching session is found with the specified URL in running state (ToiMediaSession.ToiState.STATE_RUNNING) when query parameter "SessionMode=AttachOnly" is specified in the URL.

ToiInvalidArgumentException

Raised if the URL given as argument does not follow the extended URL format, or the position is negative.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

redirectTimeshiftBuffering ( url )

Redirects the timeshift buffering to a new URL. The use case for this function is when the buffering URL need to be set or changed while playing from the timeshift buffer. If the timeshift state is TIMESHIFT_STATE_BUFFERING the buffering will stop on the current URL and then continue on the new URL. If the timeshift state is TIMESHIFT_STATE_STOPPED the buffering will just start on the new URL. The timeshift playback will continue unaffected by the redirection. If the redirection for some reason fails the player will go to live playback on the new URL. Playing from POSITION_LIVE after the redirection will also start live playback on the new URL.

Note that calling this function with high frequency will result in a fragmented buffer containing a lot of chopped pieces of content and KreaTV can not guarantee playback quality of such content. It is therefore not recommended to use this function for e.g. end user zapping.

Redirecting the timeshift buffering to a non-live media source that does not support timeshift operations will result in a timeshift state transition to {@link TIMESHIFT_STATE_BUFFERING_FAILED} with reason ToiMediaService.REASON_TIMESHIFT_BUFFER_REDIRECTED. The playback will continue to the end of the buffer.

See also:

  • ToiMediaPlayer#startTimeshiftBuffering
  • ToiMediaPlayer#stopTimeshiftBuffering
  • ToiMediaPlayer#discardTimeshiftBuffering

Parameters:

Name Type Description
url string

The URL identifying the new media source where the timeshift buffering should start or continue.

Throws:

ToiSessionViolationException

Raised if the player is in STATE_IDLE.

ToiInvalidPreconditionException

Raised if the player is not playing from the timeshift buffer or if the timeshift recording policy is not continuous. See ToiMediaPlayerBase#isTimeshiftPlayback and ToiInformationService.CFG_MEDIA_TIMESHIFT_RECORDINGPOLICY

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management. Raised if the internal timeshift player is unavailable as the result of being linked to an active MediaRecorder for timeshift playback.

releaseInstance ( )

This function releases the resources used by this instance. When this function returns all observers has also been released.

Inherited From:

  • ToiMediaPlayerBase#releaseInstance
removeEventListener ( type , listener )

This method removes an event listener for a specific event.

Inherited From:

  • ToiEventTarget#removeEventListener

Parameters:

Name Type Description
type number

The event type of the event to remove the listener from.

listener ToiEventListener

The JavaScript function that was previously added as an event listener.

Throws:

ToiInvalidArgumentException Raised if the event type is not supported by this object or if the listener is not a valid JavaScript function. This exception is also raised if the listener has not previously been added.

setAudioChannelMode ( streamId , channelMode )

This function sets the audio channel mode for a given stream identifier. For the active stream the mode will be set instantly.

Parameters:

Name Type Description
streamId number

The audio stream identifier.

channelMode ToiMediaPlayerBase.ToiAudioChannelMode

The audio channel mode.

Throws:

ToiSessionViolationException

If the player is in ToiMediaPlayerBase.STATE_IDLE a session violation exception is raised.

ToiInvalidArgumentException

An invalid argument exception is raised if the stream identifier argument does not identify a valid audio stream or the channel mode is not supported.

setParameters ( parameters )

This function sets the values of multiple parameters at once. Depending on the current state, the new values are used differently. If the function is called when in idle state, the new values are used for all sessions started after the parameters are set. If the function is called in any other state but the idle state, the new values are applied to that session only and are discarded automatically when the session ends. If an exception is raised, no parameters will be set.

See also:

  • ToiMediaPlayer#unsetParameters
  • ToiMediaPlayer#getParameters

Parameters:

Name Type Description
parameters Array.<ToiMediaSession.ToiParameter> (Or a single ToiMediaSession.ToiParameter.)

A list of parameters with name and value. A single element can be passed directly and does not need to be passed in an array.

Throws:

ToiInvalidArgumentException

Raised if an empty string is used as parameter name or a parameter value exceeds the maximum size.

ToiPermissionDeniedException

Raised if attempting to set an internal parameter.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

startTimeshiftBuffering ( maxBufferLength )

Starts background buffering of the currently viewed stream and therefore enables timeshift operations. The media player will continue to display the live stream until either pause or rewind is performed. The timeshift buffering is stopped either by an explicit call to ToiMediaPlayer#stopTimeshiftBuffering or when the buffer is full. Timeshift operations are disabled by calling ToiMediaPlayer#discardTimeshiftBuffer. If this function returns successfully, the timeshift state has changed to TIMESHIFT_STATE_BUFFERING. The behavior and preconditions for calling this function is different depending on the current timeshift recording policy configuration ToiInformationService.CFG_MEDIA_TIMESHIFT_RECORDINGPOLICY. The normal recording policy is more strict and only allows one sequence of calls, start->stop->discard and closing the media session will automatically discard the buffer. The continuous recording policy is more flexible and allows subsequent calls, start->stop->...->start->stop->discard. The continuous recording policy also keeps the timeshift buffer without discarding when closing the media session, making it possible for the timeshift buffer to follow a channel change.

See also:

  • ToiMediaPlayer#stopTimeshiftBuffering
  • ToiMediaPlayer#redirectTimeshiftBuffering
  • ToiMediaPlayer#discardTimeshiftBuffering

Parameters:

Name Type Description
maxBufferLength number

The maximum size of the timeshift buffer in seconds.

Throws:

ToiSessionViolationException

If the player is in STATE_IDLE a session violation exception is raised.

ToiInvalidArgumentException

If maxBufferLength is <= 0 an invalid argument exception is raised.

ToiInvalidPreconditionException

The preconditions is different depending on the current recording policy configuration ToiInformationService.CFG_MEDIA_TIMESHIFT_RECORDINGPOLICY. For normal timeshift recording policy the timeshift state must be TIMESHIFT_STATE_INACTIVE and the media player state must be STATE_PLAYING. The preconditions for the continuous timeshift recording policy is more loose and also allows the timeshift state to be TIMESHIFT_STATE_STOPPED, and the media player state must be STATE_PLAYING only when watching live, otherwise all other trickplay states are allowed. Any other state combination will raise an invalid precondition exception.

ToiOperationNotSupportedException

Raised if the current media source does not have the timeshift capability or if the current timeshift recording policy configuration. ToiInformationService.CFG_MEDIA_TIMESHIFT_RECORDINGPOLICY is set to continuous but continuous timeshift is not supported. This exception is also raised if the timeshift buffering should continue on a non-discarded buffer but maxBufferLength is not the same. The timeshift capacity must remain the same until the buffer is discarded.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management. Raised if timeshift buffering is temporarily unavailable due to license limitations. For example when there is another recording ongoing and DVR support is limited. Raised if the internal timeshift player is unavailable as the result of being linked to an active MediaRecorder for timeshift playback. Raised if the new timeshift is temporarily unavailable since storage device used for storing the timeshift buffer is busy during discarding the previous timeshift buffer. This exception is only valid when the timeshift buffer is stored on external device.

stopTimeshiftBuffering ( )

Stops the timeshift buffering but preserves the content in the buffer until the function ToiMediaPlayer#discardTimeshiftBuffer is called. The player will continue to play from the current media source. If this function returns successfully, the timeshift state has changed to TIMESHIFT_STATE_STOPPED.

See also:

  • ToiMediaPlayer#startTimeshiftBuffering
  • ToiMediaPlayer#redirectTimeshiftBuffering
  • ToiMediaPlayer#discardTimeshiftBuffering

Throws:

ToiSessionViolationException

If the player is in STATE_IDLE a session violation exception is raised.

ToiInvalidPreconditionException

If the timeshift state is not TIMESHIFT_STATE_BUFFERING an invalid precondition exception is raised.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management. Raised if the internal timeshift player is unavailable as the result of being linked to an active MediaRecorder for timeshift playback.

subscribeParameters ( eventListener , names )

This function makes the application subscribe to updates of the given list of parameters. The first time an application subscribes to a specific parameter there will be an immediate ToiMediaPlayerParameterChangedEvent notification if the parameter already has a value.

Inherited From:

  • ToiMediaPlayerBase#subscribeParameters

See also:

  • ToiMediaPlayerBase#unsubscribeParameters

Parameters:

Name Type Description
eventListener ToiEventListener

The eventListener that has been registered.

names Array.<ToiMediaSession.ToiParameterName> (Or a single ToiMediaSession.ToiParameterName.)

The names of the parameters for which change the application wants to subscribe to. A single element can be passed directly and does not need to be passed in an array.

Throws:

ToiInvalidArgumentException

Raised if the address name is invalid or not registered.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

unsetParameters ( names )

This function is used to remove multiple parameters at once. If the function is called when in idle state, the parameters are removed for all sessions which start after the parameters are removed. If the function is called in any other state but the idle state, the parameters are removed for that session only. If an exception is raised, no parameters will be removed.

See also:

  • ToiMediaPlayer#setParameters
  • ToiMediaPlayer#getParameters

Parameters:

Name Type Description
names Array.<ToiMediaSession.ToiParameterName> (Or a single ToiMediaSession.ToiParameterName.)

A list of names of parameters to be removed. A single element can be passed directly and does not need to be passed in an array.

Throws:

ToiInvalidArgumentException

Raised if an empty string is used as parameter name.

ToiPermissionDeniedException

Raised if attempting to unset an internal parameter.

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

unsubscribeParameters ( eventListener , names )

This function undoes the effect of a previous call to ToiMediaPlayerBase#subscribeParameters. Any parameters that has not been subscribed to will simply be ignored.

Inherited From:

  • ToiMediaPlayerBase#unsubscribeParameters

See also:

  • ToiMediaPlayerBase#subscribeParameters

Parameters:

Name Type Description
eventListener ToiEventListener

The eventListener that has been registered.

names Array.<ToiMediaSession.ToiParameterName> (Or a single ToiMediaSession.ToiParameterName.)

The names of the parameters that the application is no longer interested in. A single element can be passed directly and does not need to be passed in an array.

Throws:

ToiInvalidArgumentException

Raised if the address name is invalid or not registered

ToiUnavailableException

Raised if the player is temporarily unavailable due to platform resource management.

5.1.1.p8

Copyright (c) 2018 ARRIS Enterprises, LLC. All Rights Reserved. ARRIS Enterprises, LLC. Confidential Information.