platypush.plugins.media.mplayer

class platypush.plugins.media.mplayer.MediaMplayerPlugin(mplayer_bin=None, mplayer_timeout=0.5, args=None, *argv, **kwargs)[source]

Plugin to control MPlayer instances

Requires:

  • mplayer executable on your system
__init__(mplayer_bin=None, mplayer_timeout=0.5, args=None, *argv, **kwargs)[source]

Create the MPlayer wrapper. Note that the plugin methods are populated dynamically by introspecting the mplayer executable. You can verify the supported methods at runtime by using the list_actions method.

Parameters:
  • mplayer_bin (str) – Path to the MPlayer executable (default: search for the first occurrence in your system PATH environment variable)
  • mplayer_timeout (float) – Timeout in seconds to wait for more data from MPlayer before considering a response ready (default: 0.5 seconds)
  • subtitles (str) – Path to the subtitles file
  • args (list) – Default arguments that will be passed to the MPlayer executable
add_subtitles(filename, **args)[source]

Sets media subtitles from filename

back(offset=60.0)[source]

Back by (default: 60) seconds

execute(cmd, args=None)[source]

Execute a raw MPlayer command. See http://www.mplayerhq.hu/DOCS/tech/slave.txt for a reference or call platypush.plugins.media.mplayer.list_actions() to get a list

forward(offset=60.0)[source]

Forward by (default: 60) seconds

get_property(property, args=None)[source]

Get a player property (e.g. pause, fullscreen etc.). See http://www.mplayerhq.hu/DOCS/tech/slave.txt for a full list of the available properties

is_playing()[source]
Returns:True if it’s playing, False otherwise
load(resource, mplayer_args=None, **kwargs)[source]

Load a resource/video in the player.

mute()[source]

Toggle mute state

pause()[source]

Toggle the paused state

play(resource, subtitles=None, mplayer_args=None)[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
  • mplayer_args (list[str]) – Extra runtime arguments that will be passed to the MPlayer executable
quit()[source]

Quit the player

remove_subtitles(index=None)[source]

Removes the subtitle specified by the index (default: all)

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

Parameters:position (int) – Number of seconds from the start
set_property(property, value, args=None)[source]

Set a player property (e.g. pause, fullscreen etc.). See http://www.mplayerhq.hu/DOCS/tech/slave.txt for a full list of the available properties

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 = {
    "state": "play"  # or "stop" or "pause"
}
step_property(property, value, args=None)[source]

Step a player property (e.g. volume, time_pos etc.). See http://www.mplayerhq.hu/DOCS/tech/slave.txt for a full list of the available steppable properties

stop()[source]

Stop the playback

toggle_subtitles()[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)%