wplayer

Check-in [b9c87d983f]
Login

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

Overview
Comment:Bringup; files now play
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:b9c87d983feb4fc24c7857d41c90177109c890451e2bee1096d76542ba90550c
User & Date: ajv-899-334-8894@vsta.org 2016-01-27 17:00:40
Context
2016-01-27
22:48
Clean up layout. Ready to code file positioning. OGG file type. check-in: 0980e94b4f user: ajv-899-334-8894@vsta.org tags: master, trunk
17:00
Bringup; files now play check-in: b9c87d983f user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-01-26
22:41
Bringup check-in: b1aec2fb65 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to chore/handlers.py.

157
158
159
160
161
162
163


164
165
166
167
168
169
170
	    return True,"image/svg+xml"
	if fn.endswith(".gif"):
	    return True,"image/gif"
	if fn.endswith(".wav"):
	    return True,"audio/x-wav"
	if fn.endswith(".mp3"):
	    return True,"audio/mpeg"


	if fn.endswith(".html"):
	    return False,"text/html"
	if fn.endswith(".htm"):
	    return False,"text/html"
	if fn.endswith(".txt"):
	    return False,"text/plain"
	if fn.endswith(".json"):







>
>







157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
	    return True,"image/svg+xml"
	if fn.endswith(".gif"):
	    return True,"image/gif"
	if fn.endswith(".wav"):
	    return True,"audio/x-wav"
	if fn.endswith(".mp3"):
	    return True,"audio/mpeg"
	if fn.endswith(".flac"):
	    return True,"audio/flac"
	if fn.endswith(".html"):
	    return False,"text/html"
	if fn.endswith(".htm"):
	    return False,"text/html"
	if fn.endswith(".txt"):
	    return False,"text/plain"
	if fn.endswith(".json"):

Changes to get.py.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
63
64
65
66
67
68
69

70


71
72

73
74

75



76
77
#
# Structure of paths in the server:
#  /
#	Main UI.  Top part is playlist, bottom is file/dir browser
#  /media/<prefix>/...
#	For each prefix of files, its contents is served by
#	way of its path under here.
import os, stat

# The GET part of our handling
class GET_Mixin(object):

    # Configure our WPlayer GET treatment
    def __init__(self):

................................................................................
	return self.send_files("html/top.html")

    # Provide a directory listing.  It's JSON with lists
    #  of files and directories (sorted!) in the named path.
    def _send_dir(self, path):
	res = {}
	for path,dirs,files in os.walk(path):
	    res["files"] = sort(files)
	    res["dirs"] = sort(dirs)
	    break
	else:
	    # If the walk got nothing, provide empty lists
	    res["files"] = res["dirs"] = ()

	# Back it goes, as a JSON-encoded buffer
	return self.send_json(res)
................................................................................
		break
	else:
	    # Nope, we don't dispatch this path
	    return False,None

	# Their requested path, starting from here
	prefix = tup[1]["path"]

	path = os.path.join(prefix, os.path.join(pp[1:]))



	# File?  Or dir?

	st = os.stat(path)
	if stat.S_ISDIR(st):

	    buf = self._send_dir(path)



	    return True,buf
	return True,self.send_files(path)







|







 







|
|







 







>
|
>
>


>

|
>

>
>
>
|
<
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
..
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

#
# Structure of paths in the server:
#  /
#	Main UI.  Top part is playlist, bottom is file/dir browser
#  /media/<prefix>/...
#	For each prefix of files, its contents is served by
#	way of its path under here.
import os, stat, urllib

# The GET part of our handling
class GET_Mixin(object):

    # Configure our WPlayer GET treatment
    def __init__(self):

................................................................................
	return self.send_files("html/top.html")

    # Provide a directory listing.  It's JSON with lists
    #  of files and directories (sorted!) in the named path.
    def _send_dir(self, path):
	res = {}
	for path,dirs,files in os.walk(path):
	    res["files"] = sorted(files)
	    res["dirs"] = sorted(dirs)
	    break
	else:
	    # If the walk got nothing, provide empty lists
	    res["files"] = res["dirs"] = ()

	# Back it goes, as a JSON-encoded buffer
	return self.send_json(res)
................................................................................
		break
	else:
	    # Nope, we don't dispatch this path
	    return False,None

	# Their requested path, starting from here
	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

Changes to js/player.js.

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

74
75
76
77

78
79

80
81
82
83
84
85
86
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
    if (pcontents.dirs.length > 0) {
	res += '<b>Directories</b>:<br>';
	var d, didx = 0;
	while (didx < pcontents.dirs.length) {
	    d = pcontents.dirs[didx];
	    res += '<button onclick="go_dir(' + didx.toString() + ');">'
	    res += d;
	    res += '</button>';
	    didx += 1;
	}
    }

    // Files (if any)
    if (pcontents.files.length > 0) {
	res += '<b>Files</b>:<br>';
	var f, fidx = 0;
	while (fidx < pcontents.files.length) {
	    f = pcontents.files[fidx];
	    res += '<button onclick="go_file(' + fidx.toString() + ');">'
	    res += f;
	    res += '</button>';
	    vidx += 1;
	}
    }

    // Replace the HTML
    browser.innerHTML = res;
}

// Update playlist queue pane
function paintQueue() {

    var res = '';
    var f;
    for (f in playlist) {
	res += f + '<br>';

    }
    pqueue.innerHTML = res;

}

// For current path, get contents from web server
function curdir() {
    // Flag this op is pending
    pcontents = null;

................................................................................
	nowplaying.textContent = '';
    }
}

// Add file to playlist (or play if playlist empty)
function go_file(fidx) {
    // Assemble full filename
    var fname = path + "/" + pcontents.files[fidx]
    if (!playing) {
	nowplaying.textContent = player.src = fname;
	player.addEventListener("ended", playNext);
	player.play();
	playing = true;
    } else {
	playlist.push(fname);







|












|
|









>

<
|
|
>

<
>







 







|







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

76
77
78
79

80
81
82
83
84
85
86
87
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
    if (pcontents.dirs.length > 0) {
	res += '<b>Directories</b>:<br>';
	var d, didx = 0;
	while (didx < pcontents.dirs.length) {
	    d = pcontents.dirs[didx];
	    res += '<button onclick="go_dir(' + didx.toString() + ');">'
	    res += d;
	    res += '</button><br>\n';
	    didx += 1;
	}
    }

    // Files (if any)
    if (pcontents.files.length > 0) {
	res += '<b>Files</b>:<br>';
	var f, fidx = 0;
	while (fidx < pcontents.files.length) {
	    f = pcontents.files[fidx];
	    res += '<button onclick="go_file(' + fidx.toString() + ');">'
	    res += f;
	    res += '</button><br>\n';
	    fidx += 1;
	}
    }

    // Replace the HTML
    browser.innerHTML = res;
}

// Update playlist queue pane
function paintQueue() {
    var fidx = 0
    var res = '';

    while (fidx < playlist.length) {
	res += playlist[fidx] + '\n';
	fidx += 1;
    }

    pqueue.textContent = res;
}

// For current path, get contents from web server
function curdir() {
    // Flag this op is pending
    pcontents = null;

................................................................................
	nowplaying.textContent = '';
    }
}

// Add file to playlist (or play if playlist empty)
function go_file(fidx) {
    // Assemble full filename
    var fname = "/media" + path + "/" + pcontents.files[fidx]
    if (!playing) {
	nowplaying.textContent = player.src = fname;
	player.addEventListener("ended", playNext);
	player.play();
	playing = true;
    } else {
	playlist.push(fname);