Skip to content

Commit

Permalink
select.lua: use mp.msg.warn for unavailable messages
Browse files Browse the repository at this point in the history
  • Loading branch information
guidocella committed Dec 13, 2024
1 parent 5e4b825 commit 132faa6
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions player/lua/select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ License along with mpv. If not, see <http://www.gnu.org/licenses/>.
local utils = require "mp.utils"
local input = require "mp.input"

local function show_warning(message)
mp.msg.warn(message)
if mp.get_property_native("vo-configured") then
mp.osd_message(message)
end
end

local function show_error(message)
mp.msg.error(message)
if mp.get_property_native("vo-configured") then
Expand Down Expand Up @@ -51,7 +58,7 @@ mp.add_key_binding(nil, "select-playlist", function ()
end

if #playlist == 0 then
show_error("The playlist is empty.")
show_warning("The playlist is empty.")
return
end

Expand Down Expand Up @@ -118,7 +125,7 @@ mp.add_key_binding(nil, "select-track", function ()
end

if #tracks == 0 then
show_error("No available tracks.")
show_warning("No available tracks.")
return
end

Expand All @@ -134,7 +141,7 @@ mp.add_key_binding(nil, "select-track", function ()
})
end)

local function select_track(property, type, prompt, error)
local function select_track(property, type, prompt, warning)
local tracks = {}
local items = {}
local default_item
Expand All @@ -152,7 +159,7 @@ local function select_track(property, type, prompt, error)
end

if #items == 0 then
show_error(error)
show_warning(warning)
return
end

Expand Down Expand Up @@ -203,7 +210,7 @@ mp.add_key_binding(nil, "select-chapter", function ()
local default_item = mp.get_property_native("chapter")

if default_item == nil then
show_error("No available chapters.")
show_warning("No available chapters.")
return
end

Expand All @@ -227,7 +234,7 @@ mp.add_key_binding(nil, "select-edition", function ()
local edition_list = mp.get_property_native("edition-list")

if edition_list == nil or #edition_list == 1 then
show_error("No available editions.")
show_warning("No available editions.")
return
end

Expand All @@ -251,7 +258,7 @@ mp.add_key_binding(nil, "select-subtitle-line", function ()
local sub = mp.get_property_native("current-tracks/sub")

if sub == nil then
show_error("No subtitle is loaded.")
show_warning("No subtitle is loaded.")
return
end

Expand Down Expand Up @@ -324,7 +331,7 @@ mp.add_key_binding(nil, "select-audio-device", function ()
local default_item

if #devices == 0 then
show_error("No available audio devices.")
show_warning("No available audio devices.")
return
end

Expand Down

0 comments on commit 132faa6

Please sign in to comment.