Media#

This domain allows detailed inspection of media elements.

This CDP domain is experimental.

Types#

Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.

class PlayerId[source]#

Players will get an ID that is unique within the agent context.

class Timestamp(x=0, /)[source]#
class PlayerMessage(level, message)[source]#

Have one type per entry in MediaLogRecord::Type Corresponds to kMessage

level: str#

Keep in sync with MediaLogMessageLevel We are currently keeping the message level ‘error’ separate from the PlayerError type because right now they represent different things, this one being a DVLOG(ERROR) style log message that gets printed based on what log level is selected in the UI, and the other is a representation of a media::PipelineStatus object. Soon however we’re going to be moving away from using PipelineStatus for errors and introducing a new error type which should hopefully let us integrate the error log level into the PlayerError type.

message: str#
class PlayerProperty(name, value)[source]#

Corresponds to kMediaPropertyChange

name: str#
value: str#
class PlayerEvent(timestamp, value)[source]#

Corresponds to kMediaEventTriggered

timestamp: Timestamp#
value: str#
class PlayerErrorSourceLocation(file, line)[source]#

Represents logged source line numbers reported in an error. NOTE: file and line are from chromium c++ implementation code, not js.

file: str#
line: int#
class PlayerError(error_type, code, stack, cause, data)[source]#

Corresponds to kMediaError

error_type: str#
code: int#

Code is the numeric enum entry for a specific set of error codes, such as PipelineStatusCodes in media/base/pipeline_status.h

stack: List[PlayerErrorSourceLocation]#

A trace of where this error was caused / where it passed through.

cause: List[PlayerError]#

Errors potentially have a root cause error, ie, a DecoderError might be caused by an WindowsError

data: dict#

Extra data attached to an error, such as an HRESULT, Video Codec, etc.

class Player(player_id, dom_node_id=None)[source]#
player_id: PlayerId#
dom_node_id: Optional[BackendNodeId] = None#

Commands#

Each command is a generator function. The return type Generator[x, y, z] indicates that the generator yields arguments of type x, it must be resumed with an argument of type y, and it returns type z. In this library, types x and y are the same for all commands, and z is the return type you should pay attention to. For more information, see Getting Started: Commands.

disable()[source]#

Disables the Media domain.

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

enable()[source]#

Enables the Media domain

Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

Events#

Generally, you do not need to instantiate CDP events yourself. Instead, the API creates events for you and then you use the event’s attributes.

class PlayerPropertiesChanged(player_id, properties)[source]#

This can be called multiple times, and can be used to set / override / remove player properties. A null propValue indicates removal.

player_id: PlayerId#
properties: List[PlayerProperty]#
class PlayerEventsAdded(player_id, events)[source]#

Send events as a list, allowing them to be batched on the browser for less congestion. If batched, events must ALWAYS be in chronological order.

player_id: PlayerId#
events: List[PlayerEvent]#
class PlayerMessagesLogged(player_id, messages)[source]#

Send a list of any messages that need to be delivered.

player_id: PlayerId#
messages: List[PlayerMessage]#
class PlayerErrorsRaised(player_id, errors)[source]#

Send a list of any errors that need to be delivered.

player_id: PlayerId#
errors: List[PlayerError]#
class PlayerCreated(player)[source]#

Called whenever a player is created, or when a new agent joins and receives a list of active players. If an agent is restored, it will receive one event for each active player.

player: Player#