wplayer

Check-in [18c6501d0d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tidy UI a bit
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:18c6501d0d4fd865e6e5a0bd2a7dabf00ef32b0616d85dace18b965d9a20dcbc
User & Date: ajv-899-334-8894@vsta.org 2016-01-29 04:36:43
Context
2016-01-29
22:09
Use sendfile for efficient sending of large media. Implement range: support for player seeking of media. Implement a favicon so we get a pretty picture for our player. check-in: d98f35b757 user: ajv-899-334-8894@vsta.org tags: master, trunk
04:36
Tidy UI a bit check-in: 18c6501d0d user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-01-28
04:47
Prep for dumping into Github check-in: d1cb33aff9 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to chore/www.py.

9
10
11
12
13
14
15

16
17
18
19
20
21
22
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
	res = socket.inet_ntoa(fcntl.ioctl(
	    s.fileno(),
	    0x8915,  # SIOCGIFADDR
	    struct.pack('256s', ifname[:15])
	)[20:24])

    except:
	raise Exception, "Invalid interface name: %s" % (ifname,)

# Enable config for our HTTP listener(s)
def add_config(c):
    # A web server here; we can serve multiple ports, protocols,
    #  and interfaces
................................................................................
	    port = c.get("port", 80)

	else:
	    raise Exception, "Unknown protocol %s" % (self.proto,)

	# Standard options for socket
	s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
	ifname = c.get("ifname")
	if ifname:
	    addr = get_ip_address(ifname)
	else:
	    addr = ""
	s.bind( (addr, port) )
	s.listen(20)

	# Endless service loop
	while True:
	    conn,tup = s.accept()
	    t = threading.Thread(target=self.launch, args=(conn,tup))
	    t.start()








>







 







|













9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
	res = socket.inet_ntoa(fcntl.ioctl(
	    s.fileno(),
	    0x8915,  # SIOCGIFADDR
	    struct.pack('256s', ifname[:15])
	)[20:24])
	return res
    except:
	raise Exception, "Invalid interface name: %s" % (ifname,)

# Enable config for our HTTP listener(s)
def add_config(c):
    # A web server here; we can serve multiple ports, protocols,
    #  and interfaces
................................................................................
	    port = c.get("port", 80)

	else:
	    raise Exception, "Unknown protocol %s" % (self.proto,)

	# Standard options for socket
	s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
	ifname = c.get("iface")
	if ifname:
	    addr = get_ip_address(ifname)
	else:
	    addr = ""
	s.bind( (addr, port) )
	s.listen(20)

	# Endless service loop
	while True:
	    conn,tup = s.accept()
	    t = threading.Thread(target=self.launch, args=(conn,tup))
	    t.start()

Changes to get.py.

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
..
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
	return self.send_json(res)

    # GET dispatcher
    # See if it's a configured path, and serve file or dir
    def send_path(self):
	app = self.server
	cpaths = app.config["files"]
	pp = self.paths

	# We serve /media/prefix/blah/blah...
	if pp[0] != "media":
	    return False,None
	del pp[0]

	# Root; list configured prefixes themselves
................................................................................
	prefix = tup[1]["path"]
	if len(pp) > 1:
	    path = os.path.join(prefix, os.path.join(*pp[1:]))
	else:
	    path = prefix

	# File?  Or dir?
	path = urllib.unquote(path)
	st = os.stat(path)
	if stat.S_ISDIR(st.st_mode):
	    print "GET dir", path
	    buf = self._send_dir(path)
	else:
	    print "GET file", path
	    buf = self.send_files(path)
	return True,buf







|







 







<








49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
..
79
80
81
82
83
84
85

86
87
88
89
90
91
92
93
	return self.send_json(res)

    # GET dispatcher
    # See if it's a configured path, and serve file or dir
    def send_path(self):
	app = self.server
	cpaths = app.config["files"]
	pp = [urllib.unquote(p) for p in self.paths]

	# We serve /media/prefix/blah/blah...
	if pp[0] != "media":
	    return False,None
	del pp[0]

	# Root; list configured prefixes themselves
................................................................................
	prefix = tup[1]["path"]
	if len(pp) > 1:
	    path = os.path.join(prefix, os.path.join(*pp[1:]))
	else:
	    path = prefix

	# File?  Or dir?

	st = os.stat(path)
	if stat.S_ISDIR(st.st_mode):
	    print "GET dir", path
	    buf = self._send_dir(path)
	else:
	    print "GET file", path
	    buf = self.send_files(path)
	return True,buf

Changes to html/top.html.

1


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<html>


<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title>Web Player</title>
</head>
<body>
 <textarea rows="8" cols="80" readonly id="pqueue"></textarea>
 <hr>
 <span id="nowplaying"></span><br>
 <table>
  <tr>
   <td>
    <button onclick="return seek(-600);">-10m</button><br>
    <button onclick="return seek(-60);">-1m</button><br>
    <button onclick="return seek(-10);">-10s</button>
   </td>
   <td>
    <audio controls id="player"></audio>
   </td>
   <td>
    <button onclick="return seek(10);">+10s</button><br>
    <button onclick="return seek(60);">+1m</button><br>
    <button onclick="return seek(600);">+10m</button>
   </td>
  </tr>
 </table>
 <hr>
 <span id="browser"></span>
 <script src="/js/player.js"></script>
</body>
</html>

>
>












|

|


|













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<html>
<link rel="stylesheet" type="text/css" href="/css/normalize.css" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title>Web Player</title>
</head>
<body>
 <textarea rows="8" cols="80" readonly id="pqueue"></textarea>
 <hr>
 <span id="nowplaying"></span><br>
 <table>
  <tr>
   <td>
    <button onclick="return seek(-10);">-10s</button>
    <button onclick="return seek(-60);">-1m</button><br>
    <button onclick="return seek(-600);">-10m</button><br>
   </td>
   <td>
    <audio controls id="player" style="width: 45%;"></audio>
   </td>
   <td>
    <button onclick="return seek(10);">+10s</button><br>
    <button onclick="return seek(60);">+1m</button><br>
    <button onclick="return seek(600);">+10m</button>
   </td>
  </tr>
 </table>
 <hr>
 <span id="browser"></span>
 <script src="/js/player.js"></script>
</body>
</html>