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.
This commit is contained in:
jaseg 2019-11-30 21:15:57 +01:00
parent 3d61558714
commit 49e6f6f6d0
3 changed files with 365 additions and 6 deletions

View file

@ -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
..............