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