media.mpv#

class platypush.plugins.media.mpv.MediaMpvPlugin(args=None, *argv, **kwargs)[source]#

Bases: MediaPlugin

Plugin to control MPV instances

Requires:

  • python-mpv (pip install python-mpv)

  • mpv executable on your system

__init__(args=None, *argv, **kwargs)[source]#

Create the MPV wrapper.

Parameters:

args (dict[str, str]) – Default arguments that will be passed to the mpv executable as a key-value dict (names without the prefix). See man mpv for available options.

add_subtitles(filename)[source]#

Add a subtitles file

back(offset=30.0)[source]#

Back by (default: 30) seconds

execute(cmd, **args)[source]#

Execute a raw mpv command.

forward(offset=30.0)[source]#

Forward by (default: 30) seconds

get_property(property)[source]#

Get a player property (e.g. pause, fullscreen etc.). See man mpv for a full list of the available properties

is_playing()[source]#
Returns:

True if it’s playing, False otherwise

load(resource, **args)[source]#

Load/queue a resource/video to the player

mute()[source]#

Toggle mute state

next()[source]#

Play the next item in the queue

pause()[source]#

Toggle the paused state

play(resource, subtitles=None, **args)[source]#

Play a resource.

Parameters:
  • resource (str) – Resource to play - can be a local file or a remote URL

  • subtitles (str) – Path to optional subtitle file

  • args (dict[str,str]) – Extra runtime arguments that will be passed to the mpv executable as a key-value dict (keys without prefix)

prev()[source]#

Play the previous item in the queue

quit()[source]#

Stop and quit the player

remove_subtitles(sub_id=None)[source]#

Removes (hides) the subtitles

seek(position)[source]#

Seek backward/forward by the specified number of seconds

Parameters:

position (int) – Number of seconds relative to the current cursor

set_position(position)[source]#

Seek backward/forward to the specified absolute position (same as seek)

set_property(**props)[source]#

Set the value of an mpv property (e.g. fullscreen, sub_visibility etc.). See man mpv for a full list of properties

Parameters:

props (dict) – Key-value args for the properties to set

set_subtitles(filename, *args, **kwargs)[source]#

Sets media subtitles from filename

set_volume(volume)[source]#

Set the volume

Parameters:

volume (float) – Volume value between 0 and 100

status()[source]#

Get the current player state.

Returns:

A dictionary containing the current state.

Example:

output = {
    "filename": "filename or stream URL",
    "state": "play"  # or "stop" or "pause"
}
stop()[source]#

Stop and quit the player

toggle_fullscreen()[source]#

Toggle the fullscreen mode

toggle_property(property)[source]#

Toggle or sets the value of an mpv property (e.g. fullscreen, sub_visibility etc.). See man mpv for a full list of properties

Parameters:

property – Property to toggle

toggle_subtitles(visible=None)[source]#

Toggle the subtitles visibility

voldown(step=10.0)[source]#

Volume down by (default: 10)%

volup(step=10.0)[source]#

Volume up by (default: 10)%