jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
556 stars 69 forks source link

How to replace mpv.MpvEventID.METADATA_UPDATE ? #272

Closed project-owner closed 9 months ago

project-owner commented 9 months ago

Hi,

I recently upgraded to the lates version of the python-mpv and cannot find mpv.MpvEventID.METADATA_UPDATE anymore. It was used to detect when online radio changes track. Is there any direct replacement?

Thanks!

jaseg commented 9 months ago

You can observe the metadata property. For example:

#!/usr/bin/env python3
import mpv

player = mpv.MPV()

@player.property_observer('metadata')
def foo(property_name, new_value):
    print('metadata update', new_value)

player.play('http://stream0.wfmu.org/freeform-high.aac')
player.wait_for_playback()
project-owner commented 9 months ago

Thanks, it works! I just needed to provide input parameters to the function (property_name and new_value) https://github.com/project-owner/Peppy/blob/c4b55544bbaca5930f74c2d609bc285bc47d7629/player/mpvclient.py#L79