source: ipk/source.sh4/network_xupnpd/_path_/etc/xupnpd/xupnpd_webapp.lua

Last change on this file was 34403, checked in by Stephan, 11 years ago

missing lua

File size: 3.9 KB
Line 
1-- Copyright (C) 2011-2015 Anton Burdinuk
2-- clark15b@gmail.com
3-- https://tsdemuxer.googlecode.com/svn/trunk/xupnpd
4
5-- HTML5 Player
6
7webapp_show_playlists=true
8
9function webapp_head()
10 http_send_headers(200,'html')
11
12 http.send('<!DOCTYPE html>\r\n<html>\r\n<head><meta http-equiv="Content-type" content="text/html; charset=utf-8"/></head>\r\n<body>\r\n')
13end
14
15function webapp_tail()
16
17 http.send('</br><p align=left>\r\n')
18 http.send('Copyright (C) 2011-2015 Anton Burdinuk &lt;<a href="mailto:clark15b@gmail.com">clark15b@gmail.com</a>&gt;<br/>\r\n')
19 http.send('License: <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt">GPL-2.0</a><br/>')
20 http.send('www: <a href="http://xupnpd.org">http://xupnpd.org</a><br/></p>')
21
22 http.send('</body>\r\n</html>\r\n')
23end
24
25function webapp_play(src)
26 http.send('<video id="video1" width="640" controls>\r\n')
27 http.send(string.format('<source src="%s" type="video/mp4">\r\n',src))
28 http.send('Your browser does not support HTML5 video.\r\n</video>\r\n')
29
30 http.send('<script>\r\ndocument.getElementById("video1").play();\r\n</script>\r\n')
31
32end
33
34
35function webapp_handler(args,data,ip,url)
36
37 local action=string.match(url,'^/app/(.+)$')
38
39 if not action then action='list' end
40
41 webapp_head()
42
43 if action=='list' then
44
45 http.send('<ul>\r\n')
46
47 if not args.c then
48 for i,j in ipairs(playlist_data.elements) do
49 if j.filesystem then
50 http.send(string.format('<li><a href="/app/list?c=%s">%s</a></li>\r\n',i,j.name))
51 end
52 end
53
54 if webapp_show_playlists then
55 for i,j in ipairs(playlist_data.elements[1].elements) do
56 if j.plugin and j.type=='mp4' then
57 http.send(string.format('<li><a href="/app/list?c=1&sc=%s">%s</a></li>\r\n',i,j.name))
58 end
59 end
60 end
61
62 else
63 local c=tonumber(args.c)
64
65 if c==1 then
66 if args.sc and playlist_data.elements[c] then
67 local pls=playlist_data.elements[c].elements[tonumber(args.sc)]
68
69 for i,j in ipairs(pls.elements) do
70 if j.type=='mp4' then
71 http.send(string.format('<li><a href="/app/play?c=1&sc=%s&id=%s">%s</a></li>\r\n',args.sc,i,j.name))
72 end
73 end
74
75 end
76 else
77 if playlist_data.elements[c] and playlist_data.elements[c].filesystem then
78 for i,j in ipairs(playlist_data.elements[c].elements) do
79 if j.type=='mp4' then
80 http.send(string.format('<li><a href="/app/play?c=%s&id=%s">%s</a></li>\r\n',c,i,j.name))
81 end
82 end
83 end
84 end
85 end
86
87 http.send('</ul>')
88
89 elseif action=='play' and args.c and args.id then
90 local c=tonumber(args.c)
91 local id=tonumber(args.id)
92
93 if c==1 then
94 if args.sc and playlist_data.elements[c] then
95 local pls=playlist_data.elements[c].elements[tonumber(args.sc)]
96
97 if pls and pls.elements[id] then
98 pls=pls.elements[id]
99
100 if pls and pls.type=='mp4' and pls.plugin then
101 local u=string.format('/proxy/%s.%s',pls.objid,pls.type)
102 webapp_play(u)
103 end
104 end
105 end
106 else
107 if playlist_data.elements[c] and playlist_data.elements[c].filesystem then
108 local pls=playlist_data.elements[c].elements[id]
109
110 if pls and pls.type=='mp4' then
111 local u=string.format('/stream/%s.%s',pls.objid,pls.type)
112 webapp_play(u)
113 end
114 end
115 end
116 end
117
118 webapp_tail()
119
120end
Note: See TracBrowser for help on using the repository browser.