mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Render video ONLY if player is in focus

Open ice051128 opened this issue 2 years ago • 6 comments

Why is this not a feature in mpv? Most browsers do it natively to save power. If you are streaming a youtube video in mpv but the player is not in focus, it should only decode audio.

ice051128 avatar Nov 04 '22 07:11 ice051128

Pretty sure it does this under wayland already, if by "in focus" you mean "not hidden".

Why is this not a feature in mpv?

because you didn't implement it.

CounterPillow avatar Nov 04 '22 07:11 CounterPillow

I'm pretty sure it continues decoding the video, but it doesn't get rendered.

christoph-heinrich avatar Nov 04 '22 08:11 christoph-heinrich

[background]
profile-cond=not focused and get("current-tracks/video/albumart") == false
profile-restore=copy-equal
vid=0

In wayland, it only renders if the mpv window isn't hidden as mentioned above. x11 actually does this too as well although most WMs in practice will only send _NET_WM_STATE_HIDDEN when the window is minimized.

Dudemanguy avatar Nov 04 '22 14:11 Dudemanguy

[background]
profile-cond=not focused and get("current-tracks/video/albumart") == false
profile-restore=copy-equal
vid=0

That's probably not what the OP wants, and it's not the behaviour of browsers either. "Focus" is the wrong word here. Maybe they are looking for the term "minimize" or window occlusion.

dexeonify avatar Nov 05 '22 03:11 dexeonify

Refusing to decode video when the window isn't in focus doesn't make sense, as you create latency when you re-focus on the window.

However, mpv doesn't render the video if it wouldn't make it to the screen. At least on wayland, and I believe on x11 as well if the player is minimized.

Traneptora avatar Nov 05 '22 13:11 Traneptora

profile-cond=not focused and get("current-tracks/video/albumart") == false profile-restore=copy-equal vid=0

This code has introduced significant stuttering in audio when mpv is not in focus, why is that?

ice051128 avatar Dec 11 '22 21:12 ice051128