Skip to content

Commit

Permalink
feat(audio): add "audio-support" to status response
Browse files Browse the repository at this point in the history
This commit adds a new key "audio-support" to the status response json.

It is `false` if the only audio device found by mpv is `auto`. As this
can be subject to change, it gets reevaluated on every `/status`
request.

Related to #27
  • Loading branch information
open-dynaMIX committed Feb 19, 2020
1 parent 441f407 commit fef6a86
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions webui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,18 @@ local function log_line(request, code, length)
clientip..' - - ['..time..'] "'..path..'" '..code..' '..length..' "'..referer..'" "'..agent..'"')
end

local function is_audio_supported()
devices = mp.get_property_native('audio-device-list')
if devices[1].name == "auto" and not devices[2] then
return false
end
return true
end

local function build_status_response()
local values = {
["audio-delay"] = mp.get_property_osd("audio-delay") or '',
["audio-support"] = is_audio_supported(),
chapter = mp.get_property_native("chapter") or 0,
chapters = mp.get_property_native("chapters") or '',
duration = mp.get_property("duration") or '',
Expand Down

0 comments on commit fef6a86

Please sign in to comment.