0e4b827a82248ef643659f2ee8952675b0f5060f
[vlc.git] / 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-2006 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
34 --vlc.msg.err("requests/status.xml got:","input: "..tostring(input),"command: "..tostring(command),"id: "..tostring(id),"val: "..tostring(val))
35
36 local function stripslashes(s)
37   return string.gsub(s,"\\(%.)","%1")
38 end
39
40 local status = vlc.playlist.status()
41
42 if command == "in_play" then
43   local options = {}
44   for o in string.gmatch(input," :[^ ]*") do -- FIXME: options should be in seperate variables, not in the same string as the input.
45     table.insert(options,string.sub(o,3))
46   end
47   vlc.playlist.add({{path=stripslashes(input),options=options}})
48 elseif command == "in_enqueue" then
49   vlc.playlist.enqueue(stripslashes(input))
50 elseif command == "pl_play" then
51   vlc.playlist.goto(id)
52 elseif command == "pl_pause" then
53   vlc.msg.err("FIXME: pl_pause implementation is ugly")
54   common.hotkey("key-play-pause") -- gruik
55 elseif command == "pl_stop" then
56   vlc.playlist.stop()
57 elseif command == "pl_next" then
58   vlc.playlist.next()
59 elseif command == "pl_previous" then
60   vlc.playlist.prev()
61 elseif command == "pl_delete" then
62   vlc.msg.err("FIXME: pl_delete unimplemented")
63   --vlc.playlist.delete(id)
64 elseif command == "pl_empty" then
65   vlc.playlist.clear()
66 elseif command == "pl_sort" then
67   vlc.playlist.sort( val, id > 0 )
68 elseif command == "pl_random" then
69   vlc.playlist.random()
70 elseif command == "pl_loop" then
71   vlc.playlist.loop()
72 elseif command == "pl_repeat" then
73   vlc.playlist.repeat_()
74 elseif command == "pl_sd" then
75   if vlc.sd.is_loaded(val) then
76     vlc.sd.remove(val)
77   else
78     vlc.sd.add(val)
79   end
80 elseif command == "fullscreen" then
81   vlc.fullscreen()
82 elseif command == "snapshot" then
83   common.snapshot()
84 elseif command == "volume" then
85   vlc.volume.set(tonumber(val))
86 elseif command == "seek" then
87   common.seek(val)
88 elseif command == "key" then
89   common.hotkey("key-"..val)
90 end
91
92 local input = nil
93 local command = nil
94 local id = nil
95 local val = nil
96
97 local input = vlc.object.input()
98 local playlist = vlc.object.playlist()
99 local vout = input and vlc.object.find(input,'vout','child')
100 ?>
101 <root>
102   <volume><?vlc print(vlc.volume.get()) ?></volume>
103   <length><?vlc if input then print(vlc.var.get(input,"length")) else print(0) end?></length>
104   <time><?vlc if input then print(vlc.var.get(input,"time")) else print(0) end?></time>
105   <state><?vlc print(status) ?></state>
106   <position><?vlc if input then print(vlc.var.get(input,"position")) else print(0) end?></position>
107   <fullscreen><?vlc if vout then vlc.var.get(vout,"fullscreen") else print(0) end?></fullscreen>
108   <random><?vlc print(vlc.var.get(playlist,"random")) ?></random>
109   <loop><?vlc print(vlc.var.get(playlist,"loop")) ?></loop>
110   <repeat><?vlc print(vlc.var.get(playlist,"repeat")) ?></repeat>
111   <information>
112   <?vlc
113     if input then
114       local info = vlc.input_info()
115       for k, v in pairs(info) do
116         print("<category name='"..k.."'>")
117           for k2, v2 in pairs(v) do
118             print("<info name='"..k2.."'>"..v2.."</info>")
119           end
120         print("</category>")
121       end
122     end
123   ?>
124   </information>
125   <stats>
126   <?vlc
127     if input then
128       local stats = vlc.playlist.stats()
129       for k,v in pairs(stats) do
130         local tag = string.gsub(k,"_","")
131         print("<"..tag..">"..tostring(v).."</"..tag..">\n")
132       end
133     end
134   ?>
135   </stats>
136 </root>