lua: http: Expose renderers

This commit is contained in:
Hugo Beauzée-Luyssen 2020-05-25 15:22:43 +02:00
parent 062edb3544
commit 6ebe5a7ba1
5 changed files with 99 additions and 1 deletions

View File

@ -218,6 +218,8 @@ nobase_dist_pkgdata_DATA += \
lua/http/requests/vlm_cmd.xml \
lua/http/requests/status.xml \
lua/http/requests/status.json \
lua/http/requests/rd.json \
lua/http/requests/rd.xml \
lua/http/requests/vlm.xml \
lua/http/index.html \
lua/http/css/ui-lightness/jquery-ui-1.8.13.custom.css \

View File

@ -18,3 +18,13 @@ _G.dialogs = function(...)
end
_G.vlm = vlc.vlm()
local _rd = nil
_G.get_renderer_discovery = function()
if not _rd then
_rd = vlc.rd.create("mdns_renderer")
end
return _rd
end

View File

@ -0,0 +1,34 @@
<?vlc --[[
vim:syntax=lua
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
< rd.json: VLC media player web interface
< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
< Copyright (C) 2020 the VideoLAN team
<
< This program is free software; you can redistribute it and/or modify
< it under the terms of the GNU General Public License as published by
< the Free Software Foundation; either version 2 of the License, or
< (at your option) any later version.
<
< This program is distributed in the hope that it will be useful,
< but WITHOUT ANY WARRANTY; without even the implied warranty of
< MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
< GNU General Public License for more details.
<
< You should have received a copy of the GNU General Public License
< along with this program; if not, write to the Free Software
< Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
]]?>
<?vlc
--package.loaded.httprequests = nil --uncomment to debug changes
require "httprequests"
httprequests.processcommands()
local rdTable=httprequests.get_renderers()
httprequests.printTableAsJson(rdTable)
?>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<?vlc --[[
vim:syntax=lua
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
< rd.xml: VLC media player web interface
< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
< Copyright (C) 2020 the VideoLAN team
<
< This program is free software; you can redistribute it and/or modify
< it under the terms of the GNU General Public License as published by
< the Free Software Foundation; either version 2 of the License, or
< (at your option) any later version.
<
< This program is distributed in the hope that it will be useful,
< but WITHOUT ANY WARRANTY; without even the implied warranty of
< MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
< GNU General Public License for more details.
<
< You should have received a copy of the GNU General Public License
< along with this program; if not, write to the Free Software
< Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
]]?>
<?vlc
require "httprequests"
httprequests.processcommands()
local rdTable=httprequests.get_renderers()
print('<root>\n')
httprequests.printTableAsXml(rdTable,0)
?>
</root>

View File

@ -187,6 +187,14 @@ processcommands = function ()
vlc.player.toggle_video_track(val)
elseif command == "subtitle_track" then
vlc.player.toggle_spu_track(val)
elseif command == "set_renderer" then
local rd = get_renderer_discovery()
if not rd then
return
end
rd:select(id)
elseif command == "unset_renderer" then
rd:select(-1)
end
local input = nil
@ -426,7 +434,7 @@ getstatus = function (includecategories)
local s ={}
--update api version when new data/commands added
s.apiversion=3
s.apiversion=4
s.version=vlc.misc.version()
s.volume=vlc.volume.get()
@ -516,3 +524,10 @@ getstatus = function (includecategories)
return s
end
get_renderers = function()
local rd = get_renderer_discovery()
if not rd then
return {}
end
return rd:list()
end