mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.29k stars 2.9k forks source link

Play/Pause with TWS headphones put on/take off #10606

Closed natural-harmonia-gropius closed 2 years ago

natural-harmonia-gropius commented 2 years ago

TWS headphones support put on to play, take off to pause, It works with Youtube in edge browser. But with MPV, take off triggered the PLAYPAUSE in input.conf, put on does nothing.

Traneptora commented 2 years ago

Do you know what key is triggered at all when you put on these headphones?

natural-harmonia-gropius commented 2 years ago

I don't know.

With mpv --input-test --force-window --idle when I take off it only shows PLAYPAUSE. nothing with put on.

[input] Key PLAYPAUSE is bound to:
[input] 1.  'cycle pause' in <builtin>:1 (default)
[input] 2.  'cycle pause' in D:/OneDrive/应用/mpv/portable_config/input.conf:80
natural-harmonia-gropius commented 2 years ago

I think it's not a KeyboardEvent, mpv have same behaviors as window.addEventListener("keydown", (event) => { console.log(event) });

Should this issue keep open?

Traneptora commented 2 years ago

You can use some third-party software like AutoHotKey to log all events to see what sort of event it looks like, but if mpv doesn't have it registered then --input-test won't be able to detect it. See recent patches about F13 through F25 as an example. (Windows doesn't have this feature built-in, unfortunately.)

natural-harmonia-gropius commented 2 years ago

Media Session API can handle this.

might be useful: https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/audio/PlatformMediaSession.cpp

qwerty12 commented 2 years ago

One of the plugins that integrate mpv with Windows' media controls might enable this as a "side effect":

natural-harmonia-gropius commented 2 years ago

It works