From 49e6f6f6d0a3340c2664792cdb5bcc059dc24ea9 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 30 Nov 2019 21:15:57 +0100 Subject: Add stream protocol handling This allows you to directly feed bytes into mpv without going through a file, FIFO etc. first. The new API is: @player.register_stream_protocol(name) @player.python_stream(name, size) @player.python_stream_catchall See their docstrings for their usage. --- README.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'README.rst') diff --git a/README.rst b/README.rst index c609969..e46da2b 100644 --- a/README.rst +++ b/README.rst @@ -135,6 +135,24 @@ Playlist handling print(player.playlist) player.wait_for_playback() +Directly feeding mpv data from python +..................................... + +.. code:: python + + #!/usr/bin/env python3 + import mpv + + player = mpv.MPV() + @player.python_stream('foo') + def reader(): + with open('test.webm', 'rb') as f: + while True: + yield f.read(1024*1024) + + player.play('python://foo') + player.wait_for_playback() + PyQT embedding .............. -- cgit