jaseg / python-mpv

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

lua script not working #41

Closed za4410 closed 7 years ago

za4410 commented 7 years ago

Just tried setting script property to a lua script:

player['script'] = "/path/to/test.lua"

It gives me this error: RuntimeError: ('Generic error getting or setting mpv property', -11, (<MpvHandle object at 0x7f7e33d78a60>, b'options/script', b'/path/to/test.lua'))

It works by running mpv directly: mpv input.mov --script=/path/to/test.lua

The lua script is simply the one from mpv docs:

function on_pause_change(name, value)
    if value == true then
        mp.set_property("fullscreen", "no")
    end
end
mp.observe_property("pause", "bool", on_pause_change)
jaseg commented 7 years ago

I was able to reproduce this. The problem seems to be that mpv loads the lua scripts from the --script option on initialization and does not accept later changes to that option. From what I can tell the only way to make this work ATM is to pass script='some_script.lua to the MPV contructor. Any options you pass there will be set before the mpv handle is initialized.

za4410 commented 7 years ago

That will work! Right now when I pass script to MPV constructor it won't complain, but nothing happens either. Is this already supported?

jaseg commented 7 years ago

I'll have to look into this some more. I just tested it and the lua script gets loaded properly, but the fullscreen property does not seem to work from either lua or python when using libmpv.

jaseg commented 7 years ago

I was able to reproduce that the fullscreen property is a bit wonky on my fedora 25 but I was unable to reproduce it on debian sid running mpv v0.26.0. So I suspect that this behavior is in fact due to an upstream bug and I would suggest you to just try updating your mpv version to something really recent.

Due to a change in the options API you will also have to rename the script option in your python source code to scripts .

I'll close this issue for now. If there is anything left unclear, please go ahead and repoen it.