Change input item options handling in the lua http interface. Fixes normal playlist...
[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 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 vlc.sd.is_loaded(val) then
83     vlc.sd.remove(val)
84   else
85     vlc.sd.add(val)
86   end
87 elseif command == "fullscreen" then
88   vlc.fullscreen()
89 elseif command == "snapshot" then
90   common.snapshot()
91 elseif command == "volume" then
92   vlc.volume.set(tonumber(val))
93 elseif command == "seek" then
94   common.seek(val)
95 elseif command == "key" then
96   common.hotkey("key-"..val)
97 end
98
99 local input = nil
100 local command = nil
101 local id = nil
102 local val = nil
103
104 local input = vlc.object.input()
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(vlc.var.get(input,"length")) else print(0) end?></length>
111   <time><?vlc if input then print(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   <?vlc
120     if input then
121       local info = vlc.input_info()
122       for k, v in pairs(info) do
123         print("<category name='"..k.."'>")
124           for k2, v2 in pairs(v) do
125             print("<info name='"..k2.."'>"..v2.."</info>")
126           end
127         print("</category>")
128       end
129     end
130   ?>
131   </information>
132   <stats>
133   <?vlc
134     if input then
135       local stats = vlc.playlist.stats()
136       for k,v in pairs(stats) do
137         local tag = string.gsub(k,"_","")
138         print("<"..tag..">"..tostring(v).."</"..tag..">\n")
139       end
140     end
141   ?>
142   </stats>
143 </root>