feat: added has_many_*
disposition types
Adds `has_many_audio`, `has_many_sub`, and `has_many_video` disposition types that can be used when constructing the controls bar. The audio track selector button now has a `<has_many_audio>` disposition instead of the old `<has_audio,!audio>`.
This commit is contained in:
@@ -53,8 +53,11 @@ timeline_chapters_opacity=0.8
|
|||||||
# - `image` - true if current file is a single image
|
# - `image` - true if current file is a single image
|
||||||
# - `audio` - true for audio only files
|
# - `audio` - true for audio only files
|
||||||
# - `video` - true for files with a video track
|
# - `video` - true for files with a video track
|
||||||
|
# - `has_many_video` - true for files with more than one video track
|
||||||
# - `has_audio` - true for files with an audio track
|
# - `has_audio` - true for files with an audio track
|
||||||
|
# - `has_many_audio` - true for files with more than one audio track
|
||||||
# - `has_sub` - true for files with an subtitle track
|
# - `has_sub` - true for files with an subtitle track
|
||||||
|
# - `has_many_sub` - true for files with more than one subtitle track
|
||||||
# - `has_chapter` - true for files with chapter list
|
# - `has_chapter` - true for files with chapter list
|
||||||
# - `stream` - true if current file is read from a stream
|
# - `stream` - true if current file is read from a stream
|
||||||
# - `has_playlist` - true if current playlist has 2 or more items in it
|
# - `has_playlist` - true if current playlist has 2 or more items in it
|
||||||
@@ -77,7 +80,7 @@ timeline_chapters_opacity=0.8
|
|||||||
# fullscreen = cycle:crop_free:fullscreen:no/yes=fullscreen_exit!?Fullscreen
|
# fullscreen = cycle:crop_free:fullscreen:no/yes=fullscreen_exit!?Fullscreen
|
||||||
# loop-playlist = cycle:repeat:loop-playlist:no/inf!?Loop playlist
|
# loop-playlist = cycle:repeat:loop-playlist:no/inf!?Loop playlist
|
||||||
# toggle:{icon}:{prop} = cycle:{icon}:{prop}:no/yes!
|
# toggle:{icon}:{prop} = cycle:{icon}:{prop}:no/yes!
|
||||||
controls=menu,gap,subtitles,<has_audio,!audio>audio,<stream>stream-quality,gap,loop-playlist,loop-file,space,speed,space,prev,items,next,shuffle,gap:1,fullscreen
|
controls=menu,gap,subtitles,<has_many_audio>audio,<stream>stream-quality,gap,loop-playlist,loop-file,space,speed,space,prev,items,next,shuffle,gap:1,fullscreen
|
||||||
controls_size=32
|
controls_size=32
|
||||||
controls_size_fullscreen=40
|
controls_size_fullscreen=40
|
||||||
controls_margin=8
|
controls_margin=8
|
||||||
|
@@ -153,7 +153,7 @@ local options = {
|
|||||||
timeline_step = 5,
|
timeline_step = 5,
|
||||||
timeline_chapters_opacity = 0.8,
|
timeline_chapters_opacity = 0.8,
|
||||||
|
|
||||||
controls = 'menu,gap,subtitles,<has_audio,!audio>audio,<stream>stream-quality,gap,space,speed,space,shuffle,loop-playlist,loop-file,gap,prev,items,next,gap,fullscreen',
|
controls = 'menu,gap,subtitles,<has_many_audio>audio,<stream>stream-quality,gap,space,speed,space,shuffle,loop-playlist,loop-file,gap,prev,items,next,gap,fullscreen',
|
||||||
controls_size = 32,
|
controls_size = 32,
|
||||||
controls_size_fullscreen = 40,
|
controls_size_fullscreen = 40,
|
||||||
controls_margin = 8,
|
controls_margin = 8,
|
||||||
@@ -4111,22 +4111,22 @@ mp.observe_property('duration', 'number', create_state_setter('duration', update
|
|||||||
mp.observe_property('speed', 'number', create_state_setter('speed', update_human_times))
|
mp.observe_property('speed', 'number', create_state_setter('speed', update_human_times))
|
||||||
mp.observe_property('track-list', 'native', function(name, value)
|
mp.observe_property('track-list', 'native', function(name, value)
|
||||||
-- checks the file dispositions
|
-- checks the file dispositions
|
||||||
local has_audio, has_sub, is_video, is_image = false, false, false, false
|
local is_image = false
|
||||||
|
local types = {sub = 0, audio = 0, video = 0}
|
||||||
for _, track in ipairs(value) do
|
for _, track in ipairs(value) do
|
||||||
if track.type == 'audio' then has_audio = true end
|
|
||||||
if track.type == 'sub' then has_sub = true end
|
|
||||||
if track.type == 'video' then
|
if track.type == 'video' then
|
||||||
is_image = track.image
|
is_image = track.image
|
||||||
if not is_image and not track.albumart then
|
if not is_image and not track.albumart then types.video = types.video + 1 end
|
||||||
is_video = true
|
elseif types[track.type] then types[track.type] = types[track.type] + 1 end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
set_state('is_audio', not is_video and has_audio)
|
set_state('is_audio', types.video == 0 and types.audio > 0)
|
||||||
set_state('is_image', is_image)
|
set_state('is_image', is_image)
|
||||||
set_state('has_audio', has_audio)
|
set_state('has_audio', types.audio > 0)
|
||||||
set_state('has_sub', has_sub)
|
set_state('has_many_audio', types.audio > 1)
|
||||||
set_state('is_video', is_video)
|
set_state('has_sub', types.sub > 0)
|
||||||
|
set_state('has_many_sub', types.sub > 1)
|
||||||
|
set_state('is_video', types.video > 0)
|
||||||
|
set_state('has_many_video', types.video > 1)
|
||||||
Elements:trigger('dispositions')
|
Elements:trigger('dispositions')
|
||||||
end)
|
end)
|
||||||
mp.observe_property('chapter-list', 'native', function(_, chapters)
|
mp.observe_property('chapter-list', 'native', function(_, chapters)
|
||||||
|
Reference in New Issue
Block a user