mirror of https://github.com/mpv-player/mpv
auto_profiles: unapply conditional profiles if declared
Uses the mechanism introduced in the previous commit. The hope was to make auto-profiles easier to use, and to get rid of the need for manually created inverse profiles. Not sure if the end result is useful.
This commit is contained in:
parent
1f132c675a
commit
4c72202eb1
|
@ -789,8 +789,14 @@ Whenever a property referenced by a profile condition changes, the condition
|
|||
is re-evaluated. If the return value of the condition changes from false or
|
||||
error to true, the profile is applied.
|
||||
|
||||
Note that profiles cannot be "unapplied", so you may have to define inverse
|
||||
profiles with inverse conditions do undo a profile.
|
||||
This mechanism tries to "unapply" profiles once the condition changes from true
|
||||
to false. If you want to use this, you need to set ``profile-restore`` for the
|
||||
profile. Another possibility it to create another profile with an inverse
|
||||
condition to undo the other profile.
|
||||
|
||||
Recursive profiles can be used. But it is discouraged to reference other
|
||||
conditional profiles in a conditional profile, since this can lead to tricky
|
||||
and unintuitive behavior.
|
||||
|
||||
.. admonition:: Example
|
||||
|
||||
|
@ -804,26 +810,32 @@ profiles with inverse conditions do undo a profile.
|
|||
hue=-50
|
||||
|
||||
If you want the profile to be reverted if the condition goes to false again,
|
||||
you need to do this by manually creating an inverse profile:
|
||||
you can set ``profile-restore``:
|
||||
|
||||
::
|
||||
|
||||
[something]
|
||||
profile-desc=Flip video when entering fullscreen
|
||||
profile-desc=Mess up video when entering fullscreen
|
||||
profile-cond=fullscreen
|
||||
vf=vflip
|
||||
profile-restore=copy
|
||||
vf-add=rotate=90
|
||||
|
||||
[something2]
|
||||
profile-desc=Inverse of [something]
|
||||
This appends the ``rotate`` filter to the video filter chain when entering
|
||||
fullscreen. When leaving fullscreen, the ``vf`` option is set to the value
|
||||
it had before entering fullscreen. Note that this would also remove any
|
||||
other filters that were added during fullscreen mode by the user. Avoiding
|
||||
this is trickier, and could for example be solved by adding a second profile
|
||||
with an inverse condition and operation:
|
||||
|
||||
::
|
||||
|
||||
[something]
|
||||
profile-cond=fullscreen
|
||||
vf-add=@rot:rotate=90
|
||||
|
||||
[something-inv]
|
||||
profile-cond=not fullscreen
|
||||
vf=
|
||||
|
||||
This sets the video filter chain to ``vflip`` when entering fullscreen. The
|
||||
first profile does not cause the filter to be removed when leaving
|
||||
fullscreen. A second profile has to be defined, which is explicitly applied
|
||||
on leaving fullscreen, and which explicitly clears the filter list. (This
|
||||
would also clear the filter list at program start when starting the player
|
||||
in windowed mode.)
|
||||
vf-remove=@rot
|
||||
|
||||
.. warning::
|
||||
|
||||
|
|
|
@ -30,9 +30,14 @@ local function evaluate(profile)
|
|||
.. type(res) .. ".")
|
||||
res = false
|
||||
end
|
||||
if res ~= profile.status and res == true then
|
||||
msg.info("Applying auto profile: " .. profile.name)
|
||||
mp.commandv("apply-profile", profile.name)
|
||||
if res ~= profile.status then
|
||||
if res == true then
|
||||
msg.info("Applying auto profile: " .. profile.name)
|
||||
mp.commandv("apply-profile", profile.name)
|
||||
elseif profile.status == true and profile.has_restore_opt then
|
||||
msg.info("Restoring profile: " .. profile.name)
|
||||
mp.commandv("apply-profile", profile.name, "restore")
|
||||
end
|
||||
end
|
||||
profile.status = res
|
||||
profile.dirty = false
|
||||
|
@ -154,6 +159,7 @@ local function load_profiles()
|
|||
properties = {},
|
||||
status = nil,
|
||||
dirty = true, -- need re-evaluate
|
||||
has_restore_opt = v["profile-restore"] ~= "default"
|
||||
}
|
||||
profiles[#profiles + 1] = profile
|
||||
have_dirty_profiles = true
|
||||
|
@ -164,7 +170,7 @@ end
|
|||
load_profiles()
|
||||
|
||||
if #profiles < 1 and mp.get_property("load-auto-profiles") == "auto" then
|
||||
-- make it exist immediately
|
||||
-- make it exit immediately
|
||||
_G.mp_event_loop = function() end
|
||||
return
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue