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

ToiMediaService

Class Summary

Extends:
  • ToiEventTarget
See also:
  • ToiMediaPlayer
  • ToiMediaSession

ToiMediaService is the main interface of the Media Service. It is used by applications to create media players and sessions. Media that is being processed is represented by a media session, which can be accessed by any application through the ToiMediaService#openSession function. This allows other applications than the actual owner to get stream information, extract stream data, etc.

Service:

This is a service and can be accessed through toi.mediaService
  • Methods
  • Members
  • Types
  • Events

Method Summary

createPlayerInstance ( )  → ToiMediaPlayer Creates a new media player, and associates it with the calling application.
enumeratePlayers ( )  → Array.<ToiMediaService.ToiPlayerInfo>

This method returns a list of all active players

openSession ( sessionId )  → ToiMediaSession Opens an existing session.
subscribeType ( eventListener , type ) Subscribes to status notifications.
unsubscribeType ( eventListener , type )

This method removes a listener which has been previously subscribed to status information.

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.

removeEventListener ( type , listener )

This method removes an event listener for a specific event.

Type Definitions

ToiAssetId (Type: string)

Identifier that uniquely identifies an asset. ToiAssetManagerService.ToiAssetId

ToiPlayerType (Type: enum)

This enumeration defines the different Player types.

  • PLAYER_AUDIO
  • PLAYER_MAIN
  • PLAYER_PIP

Events

  • ON_PLAYER_STATUS_CHANGED
  • ON_SESSION_STATE_CHANGED
  • ON_SESSION_STREAM_INFO_CHANGED

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.

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.

createPlayerInstance ( )  → ToiMediaPlayer

This function creates a new media player and associates it with the calling application.

When the application no longer needs the media player, it must release it by calling ToiMediaPlayer#releaseInstance. This will return the underlying resources to the system.

See also:

  • ToiMediaPlayer
  • ToiMediaPlayer#releaseInstance

Throws:

ToiInvalidArgumentException

Raised if the specified application identifier is invalid.

ToiNotEnoughResourcesException

Raised if a new player instance cannot be created due to lack of system resources.

ToiPermissionDeniedException

Raised if the calling application is not allowed to create instances of the media player. This restriction applies to popup applications.

Returns:

The address to the ToiMediaPlayer instance.

Type: ToiMediaPlayer
enumeratePlayers ( )  → Array.<ToiMediaService.ToiPlayerInfo>

This method returns a list of all active players

Returns:

Sequence of players.

Type: Array.<ToiMediaService.ToiPlayerInfo>
openSession ( sessionId )  → ToiMediaSession

Opens an existing session. Each call to this method returns the address of a unique object that must be released when no longer needed, by calling ToiMediaSession#releaseInstance.

Note that the actual session does not necessarily have to be owned by the application calling this function. It may still be used by the owner to access the functionality of the ToiMediaSession interface.

See also:

  • ToiMediaSession

Parameters:

Name Type Description
sessionId ToiMediaSession.ToiSessionId

The identifier of the session.

Throws:

ToiInvalidArgumentException

Raised if the session identifier does not identify an existing session. Note that all applications must be designed to handle this exception since sessions can be closed at any time, rendering the session identifier invalid.

Returns:

The address of the new session object which is mapped to the requested session. The session object implements the ToiMediaSession interface.

Type: ToiMediaSession
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.

subscribeType ( eventListener , type )

This method lets the application subscribe to notifications about changes in sessions of a particular type.

See also:

  • ToiMediaService#unsubscribeType

Parameters:

Name Type Description
eventListener ToiEventListener

The eventListener that has been registered.

type ToiMediaSession.ToiSessionType

The session type.

Throws:

ToiInvalidArgumentException

If the parameter name is invalid or not recognized an invalid argument exception is raised.

unsubscribeType ( eventListener , type )

This method removes a listener which has been previously subscribed to status information.

See also:

  • ToiMediaService#subscribeType

Parameters:

Name Type Description
eventListener ToiEventListener

The eventListener that has been registered.

type ToiMediaSession.ToiSessionType

The session type.

Throws:

ToiInvalidArgumentException

If the parameter name is invalid or not recognized an invalid argument exception is raised.

Members

ON_PLAYER_STATUS_CHANGED (Type: ToiMediaPlayerStatusChangedEvent) (value = 1602) (static, constant)

This is an Event identifier for ToiMediaPlayerStatusChangedEvent.

This notification is sent whenever a player changes its state.

This constant can be also be accessed from toi.consts.ToiMediaService.ON_PLAYER_STATUS_CHANGED.
ON_SESSION_STATE_CHANGED (Type: ToiMediaSessionStateChangedEvent) (value = 1600) (static, constant)

This is an Event identifier for ToiMediaSessionStateChangedEvent.

This notification is sent when a session is changing state. A new session will initially be in state ToiMediaSession.STATE_CONNECTING while a closed session will be in state ToiMediaSession.STATE_CLOSED.

This constant can be also be accessed from toi.consts.ToiMediaService.ON_SESSION_STATE_CHANGED.
ON_SESSION_STREAM_INFO_CHANGED (Type: ToiMediaSessionStreamInfoChangedEvent) (value = 1604) (static, constant)

This is an Event identifier for ToiMediaSessionStreamInfoChangedEvent.

This notification is sent when new information about a stream handled by a session is available.

This constant can be also be accessed from toi.consts.ToiMediaService.ON_SESSION_STREAM_INFO_CHANGED.
PLAYER_AUDIO (Type: ToiMediaService.ToiPlayerType) (value = 2) (static, constant)

Audio Player type.

This constant can be also be accessed from toi.consts.ToiMediaService.PLAYER_AUDIO.
PLAYER_MAIN (Type: ToiMediaService.ToiPlayerType) (value = 0) (static, constant)

Main Player type.

This constant can be also be accessed from toi.consts.ToiMediaService.PLAYER_MAIN.
PLAYER_PIP (Type: ToiMediaService.ToiPlayerType) (value = 1) (static, constant)

Picture-In-Picture Player type.

This constant can be also be accessed from toi.consts.ToiMediaService.PLAYER_PIP.
REASON_COMMAND_CLOSE (Type: string) (value = 'CommandClose') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_COMMAND_CLOSE.
REASON_COMMAND_CONSUME (Type: string) (value = 'CommandConsume') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_COMMAND_CONSUME.
REASON_COMMAND_FASTFORWARD (Type: string) (value = 'CommandFastForward') (static, constant)

State change caused by a fast forward command

This constant can be also be accessed from toi.consts.ToiMediaService.REASON_COMMAND_FASTFORWARD.
REASON_COMMAND_OPEN (Type: string) (value = 'CommandOpen') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_COMMAND_OPEN.
REASON_COMMAND_PAUSE (Type: string) (value = 'CommandPause') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_COMMAND_PAUSE.
REASON_COMMAND_PLAY (Type: string) (value = 'CommandPlay') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_COMMAND_PLAY.
REASON_COMMAND_PLAYFROMPOSITION (Type: string) (value = 'CommandPlayFromPosition') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_COMMAND_PLAYFROMPOSITION.
REASON_COMMAND_RECORD (Type: string) (value = 'CommandRecord') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_COMMAND_RECORD.
REASON_COMMAND_REWIND (Type: string) (value = 'CommandRewind') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_COMMAND_REWIND.
REASON_ERROR_COMMAND_NOT_SUPPORTED (Type: string) (value = 'ErrorCommandNotSupported') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_COMMAND_NOT_SUPPORTED.
REASON_ERROR_CONNECTION_FAILED (Type: string) (value = 'ErrorConnectionFailed') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_CONNECTION_FAILED.
REASON_ERROR_DISK_FULL (Type: string) (value = 'ErrorStorageFull') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_DISK_FULL.
REASON_ERROR_DISK_OVERHEATED (Type: string) (value = 'ErrorStorageOverheated') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_DISK_OVERHEATED.
REASON_ERROR_HOST_UNREACHABLE (Type: string) (value = 'ErrorHostUnreachable') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_HOST_UNREACHABLE.
REASON_ERROR_INVALID_DISKASSET (Type: string) (value = 'ErrorInvalidDiskasset') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_INVALID_DISKASSET.
REASON_ERROR_INVALID_PRECONDITION (Type: string) (value = 'ErrorInvalidPrecondition') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_INVALID_PRECONDITION.
REASON_ERROR_LOWLEVEL_IO_FAILURE (Type: string) (value = 'ErrorLowlevelIOFailure') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_LOWLEVEL_IO_FAILURE.
REASON_ERROR_NO_EXTERNAL_INPUT_SIGNAL (Type: string) (value = 'ErrorNoExternalInputSignal') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_NO_EXTERNAL_INPUT_SIGNAL.
REASON_ERROR_PERMISSION_DENIED (Type: string) (value = 'ErrorPermissionDenied') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_PERMISSION_DENIED.
REASON_ERROR_POSITION_INVALID (Type: string) (value = 'ErrorPositionInvalid') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_POSITION_INVALID.
REASON_ERROR_STREAM_CLIENT (Type: string) (value = 'ErrorStreamClient') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_STREAM_CLIENT.
REASON_ERROR_STREAM_PARSING_FAILED (Type: string) (value = 'ErrorStreamParsingFailed') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_STREAM_PARSING_FAILED.
REASON_ERROR_UNEXISTING_RESOURCE (Type: string) (value = 'ErrorUnexistingResource') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_UNEXISTING_RESOURCE.
REASON_ERROR_UNSUPPORTED_DISKASSET_VERSION (Type: string) (value = 'ErrorUnsupportedDiskAssetVersion') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_UNSUPPORTED_DISKASSET_VERSION.
REASON_ERROR_UNSUPPORTED_FORMAT (Type: string) (value = 'ErrorUnsupportedFormat') (static, constant)

The current audio or video format isn't supported.

This constant can be also be accessed from toi.consts.ToiMediaService.REASON_ERROR_UNSUPPORTED_FORMAT.
REASON_POSITION_END (Type: string) (value = 'PositionEnd') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_POSITION_END.
REASON_POSITION_START (Type: string) (value = 'PositionStart') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_POSITION_START.
REASON_TIMESHIFT_BUFFER_DISCARDED (Type: string) (value = 'TimeshiftBufferDiscarded') (static, constant)

State change caused by a timeshift buffer discard command

This constant can be also be accessed from toi.consts.ToiMediaService.REASON_TIMESHIFT_BUFFER_DISCARDED.
REASON_TIMESHIFT_BUFFER_FULL (Type: string) (value = 'TimeshiftBufferFull') (static, constant)

State change caused by buffer full

This constant can be also be accessed from toi.consts.ToiMediaService.REASON_TIMESHIFT_BUFFER_FULL.
REASON_TIMESHIFT_BUFFER_OPEN (Type: string) (value = 'TimeshiftBufferOpen') (static, constant)

State change caused by player opened timeshift buffer

This constant can be also be accessed from toi.consts.ToiMediaService.REASON_TIMESHIFT_BUFFER_OPEN.
REASON_TIMESHIFT_BUFFER_REDIRECTED (Type: string) (value = 'TimeshiftBufferRedirected') (static, constant)

State change caused by a timeshift buffer redirection command

This constant can be also be accessed from toi.consts.ToiMediaService.REASON_TIMESHIFT_BUFFER_REDIRECTED.
REASON_UNKNOWN (Type: string) (value = 'Unknown') (static, constant)
This constant can be also be accessed from toi.consts.ToiMediaService.REASON_UNKNOWN.
ToiPlayerInfo (Type: struct) (static)

Information about the media player.

Struct fields

Name Description
reason

The reason for the state change.

Type: string
sessionId

The session identifier.

Type: ToiMediaSession.ToiSessionId
state

The current player state.

Type: ToiMediaPlayerBase.ToiState
type

Player Type.

Type: ToiMediaService.ToiPlayerType
url

The source URL for the media player.

Type: string

ToiSessionInfo (Type: struct) (static)

Information about a media session.

Struct fields

Name Description
id

The session identifier.

Type: ToiMediaSession.ToiSessionId
reason

The reason for the state change.

Type: string
state

The current session state.

Type: ToiMediaSession.ToiState
type

Bitmask for the types of the session, e.g. player and recorder types when the session is used for time shifting. Constants for the possible types are available in ToiMediaSession.

Type: ToiMediaSession.ToiSessionType
url

The source URL for the session.

Type: string

5.0.1

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