]> git.sesse.net Git - vlc/blob - share/lua/http/requests/status.xml
123861fea7b406e14f82c5b115d4eec3d81d4cd3
[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.playlist.pause()
61 elseif command == "pl_stop" then
62   vlc.playlist.stop()
63 elseif command == "pl_next" then
64   vlc.playlist.next()
65 elseif command == "pl_previous" then
66   vlc.playlist.prev()
67 elseif command == "pl_delete" then
68   vlc.msg.err("FIXME: pl_delete unimplemented")
69   --vlc.playlist.delete(id)
70 elseif command == "pl_empty" then
71   vlc.playlist.clear()
72 elseif command == "pl_sort" then
73   vlc.playlist.sort( val, id > 0 )
74 elseif command == "pl_random" then
75   vlc.playlist.random()
76 elseif command == "pl_loop" then
77   vlc.playlist.loop()
78 elseif command == "pl_repeat" then
79   vlc.playlist.repeat_()
80 elseif command == "pl_sd" then
81   if vlc.sd.is_loaded(val) then
82     vlc.sd.remove(val)
83   else
84     vlc.sd.add(val)
85   end
86 elseif command == "fullscreen" then
87   vlc.video.fullscreen()
88 elseif command == "snapshot" then
89   common.snapshot()
90 elseif command == "volume" then
91   common.volume(val)
92 elseif command == "seek" then
93   common.seek(val)
94 elseif command == "key" then
95   common.hotkey("key-"..val)
96 end
97
98 local input = nil
99 local command = nil
100 local id = nil
101 local val = nil
102
103 local input = vlc.object.input()
104 local item = vlc.input.item()
105 local playlist = vlc.object.playlist()
106 local vout = input and vlc.object.find(input,'vout','child')
107 ?>
108 <root>
109   <volume><?vlc print(vlc.volume.get()) ?></volume>
110   <length><?vlc if input then print(math.floor(vlc.var.get(input,"length"))) else print(0) end?></length>
111   <time><?vlc if input then print(math.floor(vlc.var.get(input,"time"))) else print(0) end?></time>
112   <state><?vlc print(status) ?></state>
113   <position><?vlc if input then print(vlc.var.get(input,"position")) else print(0) end?></position>
114   <fullscreen><?vlc if vout then vlc.var.get(vout,"fullscreen") else print(0) end?></fullscreen>
115   <random><?vlc print(vlc.var.get(playlist,"random")) ?></random>
116   <loop><?vlc print(vlc.var.get(playlist,"loop")) ?></loop>
117   <repeat><?vlc print(vlc.var.get(playlist,"repeat")) ?></repeat>
118   <information>
119     <category name="meta">
120     <?vlc
121       if item then
122         local metas = item:metas()
123         for k,v in pairs(metas) do
124           print("<info name='"..k.."'>"..vlc.strings.convert_xml_special_chars(v).."</info>")
125         end
126       end
127     ?>
128     </category>
129   <?vlc
130     if item then
131       local info = item:info()
132       for k, v in pairs(info) do
133         print("<category name='"..k.."'>")
134           for k2, v2 in pairs(v) do
135             print("<info name='"..k2.."'>"..vlc.strings.convert_xml_special_chars(v2).."</info>")
136           end
137         print("</category>")
138       end
139     end
140   ?>
141   </information>
142   <stats>
143   <?vlc
144     if item then
145       local stats = item:stats()
146       for k,v in pairs(stats) do
147         local tag = string.gsub(k,"_","")
148         print("<"..tag..">"..tostring(v).."</"..tag..">\n")
149       end
150     end
151   ?>
152   </stats>
153 </root>