media.gstreamer

class platypush.plugins.media.gstreamer.MediaGstreamerPlugin(sink: Optional[str] = None, *args, **kwargs)[source]

Plugin to play media over GStreamer.

Requires:

  • gst-python

On Debian and derived systems:

  • [sudo] apt-get install python3-gi python3-gst-1.0

On Arch and derived systems:

  • [sudo] pacman -S gst-python

__init__(sink: Optional[str] = None, *args, **kwargs)[source]
Parameters

sink – GStreamer audio sink (default: None, automatic).

back(offset=60.0)[source]

Back by (default: 60) 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=60.0)[source]

Forward by (default: 60) seconds

get_media_file_duration(filename)

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

get_volume() float[source]

Get the volume.

Returns

Volume value between 0 and 100.

is_playing()[source]
Returns

True if it’s playing, False otherwise

load(resource, **args)[source]

Load/queue a resource/video to the player (alias for play()).

mute()[source]

Toggle mute state

next()

Play the next item in the queue

pause()[source]

Toggle the paused state

play(resource: Optional[str] = None, **args)[source]

Play a resource.

Parameters

resource – Resource to play - can be a local file or a remote URL

quit()[source]

Stop and quit the player (alias for stop())

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: float) dict[source]

Seek backward/forward by the specified number of seconds.

Parameters

position – Number of seconds relative to the current cursor.

set_position(position: float) dict[source]

Seek backward/forward to the specified absolute position.

Parameters

position – Stream position in seconds.

Returns

Player state.

set_volume(volume)[source]

Set the volume.

Parameters

volume – 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() dict[source]

Get the current player state.

stop()[source]

Stop and quit the player (alias for quit())

voldown(step=10.0)[source]

Volume down by (default: 10)%

volup(step=10.0)[source]

Volume up by (default: 10)%