Giter VIP home page Giter VIP logo

Comments (11)

CogentRedTester avatar CogentRedTester commented on August 22, 2024 1

That's actually a really nice way of doing it. The mp.command function returns true when the condition evaluates to true, so it works quite well. I'd say that's a better way of doing things than the profile-command script. I don't think that conditional auto profiles were added to mpv when I initially created the script.

from mpv-scripts.

CogentRedTester avatar CogentRedTester commented on August 22, 2024

Yes and no. This script allows you to automatically run mpv input commands when a profile is applied. So for example this profile would print image to the OSD when the profile condition triggers:

[image-only]
profile-cond=p['current-tracks/video/image'] and not p['current-tracks/video/albumart']
profile-restore=copy
osd-playing-msg=
script-opts-append=profile_command-cmd= show-text "image"

While doing profile specific bindings was never the intention of this script, it can be done when using this script in conjunction with mpv input sections. You can define a keybind in input.conf as being part of a specific input section, and enable the section using profiles:

input.conf:

LEFT {image-only} playlist-prev

mpv.conf:

[image-only]
profile-cond=p['current-tracks/video/image'] and not p['current-tracks/video/albumart']
profile-restore=copy
osd-playing-msg=
script-opts-append=profile_command-cmd= enable-section image-only

Note that this will not work with profile-restore, you would need a separate profile that runs the disable-section command.

from mpv-scripts.

KonoVitoDa avatar KonoVitoDa commented on August 22, 2024

input.conf:

LEFT {image-only} playlist-prev

mpv.conf:

[image-only]
profile-cond=p['current-tracks/video/image'] and not p['current-tracks/video/albumart']
profile-restore=copy
osd-playing-msg=
script-opts-append=profile_command-cmd= enable-section image-only

This worked, thank you very much!

Note that this will not work with profile-restore, you would need a separate profile that runs the disable-section command.

I tried this, and it seemed to work:

[video-and-audio]
profile-cond=p['current-tracks/video'] or p['current-tracks/audio']
profile-restore=copy
script-opts-append=profile_command-cmd= disable-section image-only

Do you know of any better profile-cond syntax or of a better way to run it when I switch back to the default profile?

from mpv-scripts.

CogentRedTester avatar CogentRedTester commented on August 22, 2024

You could just invert the previous profile condition:

profile-cond=not (p['current-tracks/video/image'] and not p['current-tracks/video/albumart'])

from mpv-scripts.

KonoVitoDa avatar KonoVitoDa commented on August 22, 2024

You could just invert the previous profile condition:

profile-cond=not (p['current-tracks/video/image'] and not p['current-tracks/video/albumart'])

I don't know why, but it not worked.

from mpv-scripts.

CogentRedTester avatar CogentRedTester commented on August 22, 2024

This doesn't work?:

[image-only]
profile-cond=p['current-tracks/video/image'] and not p['current-tracks/video/albumart']
profile-restore=copy-equal
osd-playing-msg=
script-opts-append=profile_command-cmd= enable-section image-only

[not-image-only]
profile-cond=not (p['current-tracks/video/image'] and not p['current-tracks/video/albumart'])
profile-restore=copy-equal
script-opts-append=profile_command-cmd= disable-section image-only

from mpv-scripts.

KonoVitoDa avatar KonoVitoDa commented on August 22, 2024

Now it worked, lol, I can't figure out what I did wrong, but whatever.

By the way, probably not of your interest, but I after doing some tests I noticed the keybinds from the section {image-only} are not working well: almost always I press RIGHT to go to the next image file and it skips several files, even dozens sometimes; or I click LEFT and it won't go to the previous file, but to the next instead, or try to do both and bug; and this even occured with the default next/prev keybinds. Seems like it's some uosc-related bug, as it didn't occur when I removed uosc's folder from my scripts folder.

from mpv-scripts.

CogentRedTester avatar CogentRedTester commented on August 22, 2024

Input sections are not a widely used feature, so it's possible that uosc is doing something that messes with it. I'd suggest creating an issue on their issue tracker instead.

from mpv-scripts.

KonoVitoDa avatar KonoVitoDa commented on August 22, 2024

Input sections are not a widely used feature, so it's possible that uosc is doing something that messes with it. I'd suggest creating an issue on their issue tracker instead.

I would, but after doing more tests, I noticed the error also occurred with uosc disabled. I'll have to find a solution on my own, or simply give up haha. Thank you for all the help anyway.

from mpv-scripts.

KonoVitoDa avatar KonoVitoDa commented on August 22, 2024

Good news, I found the culprit: it's the reload.lua script.

EDIT: And this solved the bug:
4e6/mpv-reload#16 (comment)

from mpv-scripts.

KonoVitoDa avatar KonoVitoDa commented on August 22, 2024

I don't know how, but adding a mp.command at the profile-cond also works to enable sections:

[image]
profile-cond=p['current-tracks/video/image'] and not p['current-tracks/video/albumart'] and mp.command('enable-section image')
profile-restore=copy-equal
osd-playing-msg=""
prefetch-playlist
background=0.2

[not-image]
profile-cond=p['current-tracks/video/image'] == false and mp.command('disable-section image')

from mpv-scripts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.