media.omxplayer

media.omxplayer

class platypush.plugins.media.omxplayer.MediaOmxplayerPlugin(args=None, *argv, timeout: float = 20.0, **kwargs)[source]

Plugin to control video and media playback using OMXPlayer.

Requires:

  • omxplayer installed on your system (see your distro instructions)

  • omxplayer-wrapper (pip install omxplayer-wrapper)

__init__(args=None, *argv, timeout: float = 20.0, **kwargs)[source]
Parameters:
back(offset=30)[source]

Back by (default: 30) seconds

download(url, filename=None, directory=None)

Download a media URL

Parameters:
  • url – Media URL

  • filename – Media filename (default: URL filename)

  • directory – Destination directory (default: download_dir)

Returns:

The absolute path to the downloaded file

forward(offset=30)[source]

Forward by (default: 30) seconds

get_media_file_duration(filename)

Get the duration of a media file in seconds. Requires ffmpeg

get_volume() float[source]
Returns:

The player volume in percentage [0, 100].

hide_subtitles()[source]

Hide the subtitles

hide_video()[source]

Hide the video

is_playing()[source]
Returns:

True if it’s playing, False otherwise

load(resource, pause=False, **kwargs)[source]

Load a resource/video in the player.

Parameters:
  • resource (str) – URL or filename to load

  • pause (bool) – If set, load the video in paused mode (default: False)

metadata()[source]

Get the metadata of the current video

mute()[source]

Mute the player

next()[source]

Play the next track/video

pause()[source]

Pause the playback

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

Play or resume playing a resource.

Parameters:
  • resource

    Resource to play. Supported types:

    • Local files (format: file://<path>/<file>)

    • Remote videos (format: https://<url>/<resource>)

    • YouTube videos (format: https://www.youtube.com/watch?v=<id>)

    • Torrents (format: Magnet links, Torrent URLs or local Torrent files)

  • subtitles – Subtitles file

quit()[source]

Quit the player

search(query, types=None, queue_results=False, autoplay=False, search_timeout=60)

Perform a video search.

Parameters:
  • query (str) – Query string, video name or partial name

  • types (list) – Video types to search (default: ["youtube", "file", "torrent"])

  • queue_results (bool) – Append the results to the current playing queue (default: False)

  • autoplay (bool) – Play the first result of the search (default: False)

  • search_timeout (float) – Search timeout (default: 60 seconds)

seek(position)[source]

Seek to the specified number of seconds from the start.

Parameters:

position (float) – Number of seconds from the start

set_position(position)[source]

Seek to the specified number of seconds from the start (same as seek()).

Parameters:

position (float) – Number of seconds from the start

set_volume(volume)[source]

Set the volume

Parameters:

volume (float) – Volume value between 0 and 100

start_streaming(media, subtitles=None, download=False)

Starts streaming local media over the specified HTTP port. The stream will be available to HTTP clients on http://{this-ip}:{http_backend_port}/media/<media_id>

Parameters:
  • media (str) – Media to stream

  • subtitles (str) – Path or URL to the subtitles track to be used

  • download (bool) – Set to True if you prefer to download the file from the streaming link instead of streaming it

Returns:

dict containing the streaming URL.Example:

{
    "id": "0123456abcdef.mp4",
    "source": "file:///mnt/media/movies/movie.mp4",
    "mime_type": "video/mp4",
    "url": "http://192.168.1.2:8008/media/0123456abcdef.mp4"
}
status()[source]

Get the current player state.

Returns:

A dictionary containing the current state.

Format:

output = {
    "duration": Duration in seconds,
    "filename": Media filename,
    "fullscreen": true or false,
    "mute": true or false,
    "path": Media path
    "pause": true or false,
    "position": Position in seconds
    "seekable": true or false
    "state": play, pause or stop
    "title": Media title
    "url": Media url
    "volume": Volume between 0 and 100
    "volume_max": 100,
}
stop()[source]

Stop the playback (same as quit)

unmute()[source]

Unmute the player

voldown(step=10.0)[source]

Decrease the volume.

Parameters:

step (float) – Volume decrease step between 0 and 100 (default: 10%).

volup(step=10.0)[source]

Increase the volume.

Parameters:

step (float) – Volume increase step between 0 and 100 (default: 10%).

class platypush.plugins.media.omxplayer.PlayerEvent(value)[source]

An enumeration.