Skip to content

Commit

Permalink
feat: added audio indicator for audio files without cover
Browse files Browse the repository at this point in the history
ref #686
  • Loading branch information
tomasklaen committed Oct 9, 2023
1 parent c5de082 commit 27fa983
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions script-opts/uosc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions scripts/uosc/lib/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions scripts/uosc/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 27fa983

Please sign in to comment.