mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Help with Script

Open Cananbolt opened this issue 3 years ago • 11 comments

Below I have the script to pause mpv whenever it is not in focus.

pause_when_not_focused.txt

This is great, but I would like it to be only activated when video is on. In other words, files such as mp3 (and any other files) that has no video, would NOT pause mpv, when it is not focused.

Cananbolt avatar Oct 09 '22 00:10 Cananbolt

mp.get_property_native("current-tracks/video") gives you a table with information about the currently selected video track. I think it returns nil when there is currently no video track selected. Pictures also count as video track, so you might want to check the image and albumart table entries.

christoph-heinrich avatar Oct 09 '22 02:10 christoph-heinrich

You can append this profile to mpv.conf:

[focus-lost]
profile-cond=get('current-tracks/video/image') == false and not focused
profile-restore=copy
pause

guidocella avatar Oct 09 '22 06:10 guidocella

mp.get_property_native("current-tracks/video") gives you a table with information about the currently selected video track. I think it returns nil when there is currently no video track selected. Pictures also count as video track, so you might want to check the image and albumart table entries.

How can I implement this into the lua script. I apologize I'm not too familiar with lua

Cananbolt avatar Oct 09 '22 06:10 Cananbolt

You don't need a Lua script to pause an focus. That conditional profile does it. But in Lua you would use mp.get_property_native("current-tracks/video/image").

guidocella avatar Oct 09 '22 06:10 guidocella

You can append this profile to mpv.conf:

[focus-lost]
profile-cond=get('current-tracks/video/image') == false and not focused
profile-restore=copy
pause

This works however for whatever reason it messes with mpv_thumbnail_script_server.

It does not generate any thumbnails, when this profile is active

Cananbolt avatar Oct 09 '22 06:10 Cananbolt

I can't tell you why thumbnail generation breaks with this, but you could try using https://github.com/po5/thumbfast instead.

christoph-heinrich avatar Oct 09 '22 15:10 christoph-heinrich

You can append this profile to mpv.conf:

[focus-lost]
profile-cond=get('current-tracks/video/image') == false and not focused
profile-restore=copy
pause

this works great, doesn't pause music, pauses video, but it doesn't pause image slideshow when i use mpv to "play back" a photo album. how would you modify it for it to do that? shouldn't /video/image pause for images?

markifi avatar Oct 19 '22 18:10 markifi

You can append this profile to mpv.conf:

[focus-lost]
profile-cond=get('current-tracks/video/image') == false and not focused
profile-restore=copy
pause

this works great, doesn't pause music, pauses video, but it doesn't pause image slideshow when i use mpv to "play back" a photo album. how would you modify it for it to do that? shouldn't /video/image pause for images?

As I mentioned above, this works however for whatever reason it messes with mpv_thumbnail_script_server.

It does not generate any thumbnails, when this conditioner profile is active. Thanks for the help though

Cananbolt avatar Oct 19 '22 18:10 Cananbolt

this works great, doesn't pause music, pauses video, but it doesn't pause image slideshow when i use mpv to "play back" a photo album. how would you modify it for it to do that? shouldn't /video/image pause for images?

profile-cond=get('current-tracks/video/albumart') == false and not focused

guidocella avatar Oct 19 '22 19:10 guidocella

('current-tracks/video/albumart') == false and not focused` that works and pauses image slideshows. apologies OP for hijacking the thread for my purposes. i see this was also mentioned above I didn't know where to include it because I'm new to these configs. cheers

markifi avatar Oct 19 '22 19:10 markifi

('current-tracks/video/albumart') == false and not focused` that works and pauses image slideshows. apologies OP for hijacking the thread for my purposes. i see this was also mentioned above I didn't know where to include it because I'm new to these configs. cheers

Hey no worries, glad you got what you were looking for.

Cananbolt avatar Oct 19 '22 19:10 Cananbolt

You can append this profile to mpv.conf:

[focus-lost]
profile-cond=get('current-tracks/video/image') == false and not focused
profile-restore=copy
pause

I switched over to thumbfast and this works perfectly. Thanks for the help

Cananbolt avatar Dec 17 '22 17:12 Cananbolt