Comments (11)
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.
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.
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 thedisable-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.
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.
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.
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.
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.
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.
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.
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.
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)
- All the ' are displayed as ' when searching HOT 4
- youtube-search: youtube API does not accept search HOT 22
- youtube-search: ctrl+i breaks searching. HOT 2
- YouTube Search Feature Request: use Invidious/Newpipe API as an option? HOT 16
- Documentation: Unclear on how to set it up HOT 3
- youtube-search: Update Description in README.md
- Add it mplug script directory
- `command-timeout.lua`: `screenshot` command doesn't print any OSD message HOT 3
- youtube-search: curl not returning search list HOT 3
- youtube-search.lua: Use yt-dlp instead of curl+API HOT 3
- keep-session.lua: "auto_load" resize mpv window although mpv.conf "auto-window-resize=no" HOT 2
- keep-session: add an option to remeber only the last opened video, not the playlist HOT 6
- script-name: keep-session.lua HOT 1
- [cycle-profile] How to restore default profile? HOT 10
- Youtube-search: Need help to change the keybind in input.conf HOT 1
- youtube-search: doesn't work with the newest version of mpv (0.38) HOT 1
- [Feature Request] Exclude folders in keep-session.lua
- New cycle-commands syntax error with sharp sign HOT 7
- How to specify no-osd with the new syntax of the Cycle-commands plugin? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mpv-scripts.