]> git.sesse.net Git - vlc/blob - share/lua/http/requests/status.xml
luahttp: fix service discovery loading.
[vlc] / share / lua / http / requests / status.xml
1 <?xml version="1.0" encoding="utf-8" standalone="yes" ?<?vlcprint'>'?>
2 <?vlc --[[
3 vim:syntax=lua
4 <!--  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
5 <  status.xml: VLC media player web interface
6 < - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >
7 <  Copyright (C) 2005-2009 the VideoLAN team
8 <  $Id$
9
10 <  Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
11
12 <  This program is free software; you can redistribute it and/or modify
13 <  it under the terms of the GNU General Public License as published by
14 <  the Free Software Foundation; either version 2 of the License, or
15 <  (at your option) any later version.
16
17 <  This program is distributed in the hope that it will be useful,
18 <  but WITHOUT ANY WARRANTY; without even the implied warranty of
19 <  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 <  GNU General Public License for more details.
21
22 <  You should have received a copy of the GNU General Public License
23 <  along with this program; if not, write to the Free Software
24 <  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 < - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
26 ]]?>
27 <?vlc
28
29 local input = _GET['input']
30 local command = _GET['command']
31 local id = tonumber(_GET['id'] or -1)
32 local val = _GET['val']
33 local options = _GET['option']
34 if type(options) ~= "table" then -- Deal with the 0 or 1 option case
35   options = { options }
36 end
37
38 ---[[]] vlc.msg.err("requests/status.xml got:","input: "..tostring(input),"command: "..tostring(command),"id: "..tostring(id),"val: "..tostring(val))
39
40 local function stripslashes(s)
41   return string.gsub(s,"\\(%.)","%1")
42 end
43
44 local status = vlc.playlist.status()
45
46 if command == "in_play" then
47   ---[[
48   vlc.msg.err( "<options>" )
49   for a,b in ipairs(options) do
50     vlc.msg.err(b)
51   end
52   vlc.msg.err( "</options>" )
53   --]]
54   vlc.playlist.add({{path=stripslashes(input),options=options}})
55 elseif command == "in_enqueue" then
56   vlc.playlist.enqueue({{path=stripslashes(input),options=options}})
57 elseif command == "pl_play" then
58   vlc.playlist.goto(id)
59 elseif command == "pl_pause" then
60   vlc.msg.err("FIXME: pl_pause implementation is ugly")
61   common.hotkey("key-play-pause") -- gruik
62 elseif command == "pl_stop" then
63   vlc.playlist.stop()
64 elseif command == "pl_next" then
65   vlc.playlist.next()
66 elseif command == "pl_previous" then
67   vlc.playlist.prev()
68 elseif command == "pl_delete" then
69   vlc.msg.err("FIXME: pl_delete unimplemented")
70   --vlc.playlist.delete(id)
71 elseif command == "pl_empty" then
72   vlc.playlist.clear()
73 elseif command == "pl_sort" then
74   vlc.playlist.sort( val, id > 0 )
75 elseif command == "pl_random" then
76   vlc.playlist.random()
77 elseif command == "pl_loop" then
78   vlc.playlist.loop()
79 elseif command == "pl_repeat" then
80   vlc.playlist.repeat_()
81 elseif command == "pl_sd" then
82   if(_GET['islua'] == "1") then
83     sdname = "lua{sd='" .. val .. "'}"
84   else
85     sdname = val
86   end
87   if vlc.sd.is_loaded(sdname) then
88     vlc.sd.remove(sdname)
89   else
90     vlc.sd.add(sdname)
91   end
92 elseif command == "fullscreen" then
93   vlc.fullscreen()
94 elseif command == "snapshot" then
95   common.snapshot()
96 elseif command == "volume" then
97   common.volume(val)
98 elseif command == "seek" then
99   common.seek(val)
100 elseif command == "key" then
101   common.hotkey("key-"..val)
102 end
103
104 local input = nil
105 local command = nil
106 local id = nil
107 local val = nil
108
109 local input = vlc.object.input()
110 local item = vlc.input.item()
111 local playlist = vlc.object.playlist()
112 local vout = input and vlc.object.find(input,'vout','child')
113 ?>
114 <root>
115   <volume><?vlc print(vlc.volume.get()) ?></volume>
116   <length><?vlc if input then print(math.floor(vlc.var.get(input,"length"))) else print(0) end?></length>
117   <time><?vlc if input then print(math.floor(vlc.var.get(input,"time"))) else print(0) end?></time>
118   <state><?vlc print(status) ?></state>
119   <position><?vlc if input then print(vlc.var.get(input,"position")) else print(0) end?></position>
120   <fullscreen><?vlc if vout then vlc.var.get(vout,"fullscreen") else print(0) end?></fullscreen>
121   <random><?vlc print(vlc.var.get(playlist,"random")) ?></random>
122   <loop><?vlc print(vlc.var.get(playlist,"loop")) ?></loop>
123   <repeat><?vlc print(vlc.var.get(playlist,"repeat")) ?></repeat>
124   <information>
125     <category name="meta">
126     <?vlc
127       if item then
128         local metas = item:metas()
129         for k,v in pairs(metas) do
130           print("<info name='"..k.."'>"..vlc.strings.convert_xml_special_chars(v).."</info>")
131         end
132       end
133     ?>
134     </category>
135   <?vlc
136     if item then
137       local info = item:info()
138       for k, v in pairs(info) do
139         print("<category name='"..k.."'>")
140           for k2, v2 in pairs(v) do
141             print("<info name='"..k2.."'>"..vlc.strings.convert_xml_special_chars(v2).."</info>")
142           end
143         print("</category>")
144       end
145     end
146   ?>
147   </information>
148   <stats>
149   <?vlc
150     if item then
151       local stats = item:stats()
152       for k,v in pairs(stats) do
153         local tag = string.gsub(k,"_","")
154         print("<"..tag..">"..tostring(v).."</"..tag..">\n")
155       end
156     end
157   ?>
158   </stats>
159 </root>