diff options
author | jaseg <git@jaseg.net> | 2017-05-21 13:39:08 +0200 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2017-05-21 13:39:08 +0200 |
commit | f841f343cf6fea5f8b6bd1bddbef5e7452a73e66 (patch) | |
tree | 3bcc1fc65216b65b5305c38ed8a894c284ac4d1f | |
parent | 76027e6fa6b42b71ca4fd008ae8dc971646305b8 (diff) | |
download | python-mpv-f841f343cf6fea5f8b6bd1bddbef5e7452a73e66.tar.gz python-mpv-f841f343cf6fea5f8b6bd1bddbef5e7452a73e66.tar.bz2 python-mpv-f841f343cf6fea5f8b6bd1bddbef5e7452a73e66.zip |
README: Fix property observer example
-rw-r--r-- | README.rst | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -1,3 +1,5 @@ +.. vim: tw=120 sw=4 et + python-mpv ========== @@ -52,7 +54,12 @@ Advanced Usage player = mpv.MPV(log_handler=my_log, ytdl=True, input_default_bindings=True, input_vo_keyboard=True) # Property access, these can be changed at runtime - player.observe_property('time-pos', lambda pos: print('Now playing at {:.2f}s'.format(pos))) + @player.property_observer('time-pos') + def time_observer(_name, value): + # Here, _value is either None if nothing is playing or a float containing + # fractional seconds since the beginning of the file. + print('Now playing at {:.2f}s'.format(value))) + player.fullscreen = True player.loop = 'inf' # Option access, in general these require the core to reinitialize |