media

Platypush documentation

media#

class platypush.message.event.media.MediaDownloadCancelledEvent(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)[source]#

Bases: MediaDownloadEvent

Event triggered when a media download is cancelled.

__init__(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)#
Parameters:
  • resource – File name or URI of the downloaded resource

  • url – Alias for resource

  • path – Path where the resource is downloaded

  • state – Download state

  • size – Size of the downloaded resource in bytes

  • timeout – Download timeout in seconds

  • progress – Download progress in percentage, between 0 and 100

  • started_at – Download start time

  • ended_at – Download end time

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaDownloadClearEvent(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)[source]#

Bases: MediaDownloadEvent

Event triggered when a download is cleared from the queue.

__init__(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)#
Parameters:
  • resource – File name or URI of the downloaded resource

  • url – Alias for resource

  • path – Path where the resource is downloaded

  • state – Download state

  • size – Size of the downloaded resource in bytes

  • timeout – Download timeout in seconds

  • progress – Download progress in percentage, between 0 and 100

  • started_at – Download start time

  • ended_at – Download end time

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaDownloadCompletedEvent(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)[source]#

Bases: MediaDownloadEvent

Event triggered when a media download is completed.

__init__(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)#
Parameters:
  • resource – File name or URI of the downloaded resource

  • url – Alias for resource

  • path – Path where the resource is downloaded

  • state – Download state

  • size – Size of the downloaded resource in bytes

  • timeout – Download timeout in seconds

  • progress – Download progress in percentage, between 0 and 100

  • started_at – Download start time

  • ended_at – Download end time

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaDownloadErrorEvent(error: str, *args, **kwargs)[source]#

Bases: MediaDownloadEvent

Event triggered when a media download fails.

__init__(error: str, *args, **kwargs)[source]#
Parameters:

error – Error message.

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaDownloadEvent(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)[source]#

Bases: MediaEvent, ABC

Base class for media download events.

__init__(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)[source]#
Parameters:
  • resource – File name or URI of the downloaded resource

  • url – Alias for resource

  • path – Path where the resource is downloaded

  • state – Download state

  • size – Size of the downloaded resource in bytes

  • timeout – Download timeout in seconds

  • progress – Download progress in percentage, between 0 and 100

  • started_at – Download start time

  • ended_at – Download end time

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaDownloadPausedEvent(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)[source]#

Bases: MediaDownloadEvent

Event triggered when a media download is paused.

__init__(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)#
Parameters:
  • resource – File name or URI of the downloaded resource

  • url – Alias for resource

  • path – Path where the resource is downloaded

  • state – Download state

  • size – Size of the downloaded resource in bytes

  • timeout – Download timeout in seconds

  • progress – Download progress in percentage, between 0 and 100

  • started_at – Download start time

  • ended_at – Download end time

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaDownloadProgressEvent(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)[source]#

Bases: MediaDownloadEvent

Event triggered when a media download is in progress.

__init__(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)#
Parameters:
  • resource – File name or URI of the downloaded resource

  • url – Alias for resource

  • path – Path where the resource is downloaded

  • state – Download state

  • size – Size of the downloaded resource in bytes

  • timeout – Download timeout in seconds

  • progress – Download progress in percentage, between 0 and 100

  • started_at – Download start time

  • ended_at – Download end time

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaDownloadResumedEvent(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)[source]#

Bases: MediaDownloadEvent

Event triggered when a media download is resumed.

__init__(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)#
Parameters:
  • resource – File name or URI of the downloaded resource

  • url – Alias for resource

  • path – Path where the resource is downloaded

  • state – Download state

  • size – Size of the downloaded resource in bytes

  • timeout – Download timeout in seconds

  • progress – Download progress in percentage, between 0 and 100

  • started_at – Download start time

  • ended_at – Download end time

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaDownloadStartedEvent(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)[source]#

Bases: MediaDownloadEvent

Event triggered when a media download is started.

__init__(*args, plugin: str, resource: str, state: str, path: str, player: str | None = None, size: int | None = None, timeout: int | None = None, progress: float | None = None, started_at: float | None = None, ended_at: float | None = None, **kwargs)#
Parameters:
  • resource – File name or URI of the downloaded resource

  • url – Alias for resource

  • path – Path where the resource is downloaded

  • state – Download state

  • size – Size of the downloaded resource in bytes

  • timeout – Download timeout in seconds

  • progress – Download progress in percentage, between 0 and 100

  • started_at – Download start time

  • ended_at – Download end time

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaEvent(*args, player=None, plugin=None, status=None, **kwargs)[source]#

Bases: Event

Base class for media events

__init__(*args, player=None, plugin=None, status=None, **kwargs)[source]#
Parameters:
  • target (str) – Target node

  • origin (str) – Origin node (default: current node)

  • id (str) – Event ID (default: auto-generated)

  • timestamp (float) – Event timestamp (default: current time)

  • logging_level – Logging level for this event (default: logging.INFO)

  • disable_web_clients_notification – Don’t send a notification of this event to the websocket clients

  • kwargs – Additional arguments for the event

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaMuteChangedEvent(mute, player=None, plugin=None, *args, **kwargs)[source]#

Bases: MediaEvent

Event triggered when the media is muted/unmuted

__init__(mute, player=None, plugin=None, *args, **kwargs)[source]#
Parameters:
  • target (str) – Target node

  • origin (str) – Origin node (default: current node)

  • id (str) – Event ID (default: auto-generated)

  • timestamp (float) – Event timestamp (default: current time)

  • logging_level – Logging level for this event (default: logging.INFO)

  • disable_web_clients_notification – Don’t send a notification of this event to the websocket clients

  • kwargs – Additional arguments for the event

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaPauseEvent(player=None, plugin=None, *args, **kwargs)[source]#

Bases: MediaEvent

Event triggered when a media playback is paused

__init__(player=None, plugin=None, *args, **kwargs)[source]#
Parameters:
  • target (str) – Target node

  • origin (str) – Origin node (default: current node)

  • id (str) – Event ID (default: auto-generated)

  • timestamp (float) – Event timestamp (default: current time)

  • logging_level – Logging level for this event (default: logging.INFO)

  • disable_web_clients_notification – Don’t send a notification of this event to the websocket clients

  • kwargs – Additional arguments for the event

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaPlayEvent(player=None, plugin=None, resource=None, title=None, *args, **kwargs)[source]#

Bases: MediaEvent

Event triggered when a new media content is played

__init__(player=None, plugin=None, resource=None, title=None, *args, **kwargs)[source]#
Parameters:

resource (str) – File name or URI of the played video

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaPlayRequestEvent(player=None, plugin=None, resource=None, title=None, *args, **kwargs)[source]#

Bases: MediaEvent

Event triggered when a new media playback request is received

__init__(player=None, plugin=None, resource=None, title=None, *args, **kwargs)[source]#
Parameters:

resource (str) – File name or URI of the played video

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaResumeEvent(player=None, plugin=None, *args, **kwargs)[source]#

Bases: MediaEvent

Event triggered when a media playback is resumed

__init__(player=None, plugin=None, *args, **kwargs)[source]#
Parameters:
  • target (str) – Target node

  • origin (str) – Origin node (default: current node)

  • id (str) – Event ID (default: auto-generated)

  • timestamp (float) – Event timestamp (default: current time)

  • logging_level – Logging level for this event (default: logging.INFO)

  • disable_web_clients_notification – Don’t send a notification of this event to the websocket clients

  • kwargs – Additional arguments for the event

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaSeekEvent(position, player=None, plugin=None, *args, **kwargs)[source]#

Bases: MediaEvent

Event triggered when the time position in the media changes

__init__(position, player=None, plugin=None, *args, **kwargs)[source]#
Parameters:
  • target (str) – Target node

  • origin (str) – Origin node (default: current node)

  • id (str) – Event ID (default: auto-generated)

  • timestamp (float) – Event timestamp (default: current time)

  • logging_level – Logging level for this event (default: logging.INFO)

  • disable_web_clients_notification – Don’t send a notification of this event to the websocket clients

  • kwargs – Additional arguments for the event

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaStopEvent(player=None, plugin=None, *args, **kwargs)[source]#

Bases: MediaEvent

Event triggered when a media is stopped

__init__(player=None, plugin=None, *args, **kwargs)[source]#
Parameters:
  • target (str) – Target node

  • origin (str) – Origin node (default: current node)

  • id (str) – Event ID (default: auto-generated)

  • timestamp (float) – Event timestamp (default: current time)

  • logging_level – Logging level for this event (default: logging.INFO)

  • disable_web_clients_notification – Don’t send a notification of this event to the websocket clients

  • kwargs – Additional arguments for the event

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.MediaVolumeChangedEvent(volume, player=None, plugin=None, *args, **kwargs)[source]#

Bases: MediaEvent

Event triggered when the media volume changes

__init__(volume, player=None, plugin=None, *args, **kwargs)[source]#
Parameters:
  • target (str) – Target node

  • origin (str) – Origin node (default: current node)

  • id (str) – Event ID (default: auto-generated)

  • timestamp (float) – Event timestamp (default: current time)

  • logging_level – Logging level for this event (default: logging.INFO)

  • disable_web_clients_notification – Don’t send a notification of this event to the websocket clients

  • kwargs – Additional arguments for the event

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object

class platypush.message.event.media.NewPlayingMediaEvent(player=None, plugin=None, resource=None, *args, **kwargs)[source]#

Bases: MediaEvent

Event triggered when a new media source is being played

__init__(player=None, plugin=None, resource=None, *args, **kwargs)[source]#
Parameters:

resource (str) – File name or URI of the played resource

as_dict()#

Converts the event into a dictionary

classmethod build(msg)#

Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event

matches_condition(condition)#

If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object

classmethod parse(msg)#

Parse a generic message into a key-value dictionary

Parameters:

msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON

classmethod to_dict(msg)#

Converts a Message object into a dictionary

Parameters:

msg – Message object