I followed the documentation to use JavaScript in plugins. But apparently that feature is not working. I use no configuration files and --script flag via command line couldn't work either. Also, Lua version of this script works okay.
macOS, HEAD https://github.com/mpv-player/mpv/commit/a9a4d6349a2d92200d80382532bff46971aafdae
~/.config/mpv/scripts/test.js.js
function on_pause_change(name, value) {
if (value == true)
mp.set_property("fullscreen", "no");
}
mp.observe_property("pause", "bool", on_pause_change);
Script should perform its correct functionality.
Script is not working.
[ 0.041][v][cplayer] Can't load unknown script: /Users/Kutsan/.config/mpv/scripts/test.js
My guess is that your mpv build was not compiled with javascript support. You can check it by running:
mpv -v
and checking for javascript at the section List of enabled features: ....
@avih Yes, you are right; I can't find javascript there but how can I compile with JavaScript support? I couldn't have seen anything about JavaScript in docs.
If you compile mpv yourself, then you first need to compile and install mujs:
git clone https://github.com/ccxvii/mujs.git
cd mujs
make release
sudo make install # installs to /usr/local . optionally add prefix=/path/to/elsewhere
and then compile mpv again.
Thank you! I did and compiled with --enable-javascript flag and it works now!
compiled with --enable-javascript flag
That's optional. If mujs is installed and mpv can find it, then it will be enabled automatically.
Oh, I'll keep this in my mind.
For others, I created a PR https://github.com/Homebrew/homebrew-core/pull/22431 for Homebrew for macOS and it's accepted. If you are using macOS, all you need to do is:
brew install mpv
It installs MuJS and compiles with JavaScript support by default. Previously, this wasn't the case.
Note that, unofficial mpv bundle application at brew cask does not come with JavaScript support. So, you don't need that. Instead, this will do for native macOS application.
brew install mpv --with-bundle
brew link mpv
Most helpful comment
If you compile mpv yourself, then you first need to compile and install mujs:
and then compile mpv again.