From 27fa983046a6beff5c5a5d7d9b364cab161ab0f0 Mon Sep 17 00:00:00 2001 From: tomasklaen Date: Mon, 9 Oct 2023 11:41:07 +0200 Subject: [PATCH] feat: added audio indicator for audio files without cover ref #686 --- script-opts/uosc.conf | 1 + scripts/uosc/lib/utils.lua | 7 +++++++ scripts/uosc/main.lua | 2 ++ 3 files changed, 10 insertions(+) diff --git a/script-opts/uosc.conf b/script-opts/uosc.conf index 98447aef..ac7b29b3 100644 --- a/script-opts/uosc.conf +++ b/script-opts/uosc.conf @@ -52,6 +52,7 @@ progress_line_width=20 # - `audio` - true for audio only files # - `video` - true for files with a video track # - `has_many_video` - true for files with more than one video track +# - `has_image` - true for files with a cover or other image 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 diff --git a/scripts/uosc/lib/utils.lua b/scripts/uosc/lib/utils.lua index 3874903e..d6c49ff6 100644 --- a/scripts/uosc/lib/utils.lua +++ b/scripts/uosc/lib/utils.lua @@ -655,6 +655,13 @@ function render() -- Actual rendering local ass = assdraw.ass_new() + -- Audio indicator + if state.is_audio and not state.has_image then + local smaller_side = math.min(display.width, display.height) + ass:icon(display.width / 2, display.height / 2, smaller_side / 3, 'graphic_eq', {color = fg, opacity = 0.5}) + end + + -- Elements for _, element in Elements:ipairs() do if element.enabled then local result = element:maybe('render') diff --git a/scripts/uosc/main.lua b/scripts/uosc/main.lua index af757d4e..c4e32979 100644 --- a/scripts/uosc/main.lua +++ b/scripts/uosc/main.lua @@ -424,6 +424,7 @@ state = { is_audio = false, -- true if file is audio only (mp3, etc) is_image = false, is_stream = false, + has_image = false, has_audio = false, has_sub = false, has_chapter = false, @@ -747,6 +748,7 @@ mp.observe_property('track-list', 'native', function(name, value) end set_state('is_audio', types.video == 0 and types.audio > 0) set_state('is_image', types.image > 0 and types.video == 0 and types.audio == 0) + set_state('has_image', types.image > 0) set_state('has_audio', types.audio > 0) set_state('has_many_audio', types.audio > 1) set_state('has_sub', types.sub > 0)