wplayer

Check-in [7d0b100321]
Login

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

Overview
Comment:Work on now playing data display. Add "drop all" list.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:7d0b100321fd6dfe93e8bb73f00849590d59300a4edc51ee0fd64fdbcf17b5e5
User & Date: ajv-899-334-8894@vsta.org 2016-06-18 03:27:41
Context
2016-11-21
22:08
Normalize capitalization of mixins. Switch to account server. check-in: 264e89591f user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-06-18
03:27
Work on now playing data display. Add "drop all" list. check-in: 7d0b100321 user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-02-12
03:32
Add drop first/last from queue, and add all album check-in: 5ca5f19a17 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to html/top.html.

31
32
33
34
35
36
37

38
39
40
41
42
43
44
 <hr>
 <button onclick="return go_up();">
  <img src="/imgs/player_eject.png" alt="Go Up" />
 </button>
 <button onclick="return dropFirst();">-First</button>
 <button onclick="return dropLast();">-Last</button>
 <button onclick="return addAll();">+All</button>

 <br>
 <textarea rows="1" cols="40" readonly id="trackname"></textarea>
 <br>
 <span id="browser"></span>
 <script src="/js/player.js"></script>
</body>
</html>







>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 <hr>
 <button onclick="return go_up();">
  <img src="/imgs/player_eject.png" alt="Go Up" />
 </button>
 <button onclick="return dropFirst();">-First</button>
 <button onclick="return dropLast();">-Last</button>
 <button onclick="return addAll();">+All</button>
 <button onclick="return dropAll();">-All</button>
 <br>
 <textarea rows="1" cols="40" readonly id="trackname"></textarea>
 <br>
 <span id="browser"></span>
 <script src="/js/player.js"></script>
</body>
</html>

Changes to js/player.js.

12
13
14
15
16
17
18



19
20
21
22
23
24
25
..
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
..
70
71
72
73
74
75
76
77



























78
79
80
81
82

83
84
85
86
87
88
89
...
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
...
184
185
186
187
188
189
190








191
192
193
194
195
196
197

// Show the queue of tracks
var pqueue = document.getElementById("pqueue");

// Where to stash text of current track path
var trackname = document.getElementById("trackname");




// The playlist queue
var playlist = [];

// Current browsing path, and how "deep" we are down into it
var path = "";
var pdepth = 0;
// This will be path's contents; it goes to null while
................................................................................

    //
    // Paint file browsing window
    //
    res = ''

    // Name of active track in its own position
    trackname.textContent = unescape(path);

    // Directories (if any)
    if (pcontents.dirs.length > 0) {
	res += '<b>Directories</b>:<br>';
	for (var didx = 0; didx < pcontents.dirs.length; didx++) {
	    d = pcontents.dirs[didx];
	    res += '<button onclick="return go_dir(' + didx.toString() + ');">'
................................................................................
	    res += '</button>' + unescape(f) + '<br>\n'
	}
    }

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




























// Update playlist queue pane
function paintQueue() {
    var res = '';
    for (var fidx = 0; fidx < playlist.length; fidx++) {
	res += unescape(playlist[fidx]) + '\n';

    }
    pqueue.textContent = res;
}

// For current path, get contents from web server
function curdir() {
    // Flag this op is pending
................................................................................
    if (playlist.length > 0) {
	var s = playlist.shift();
	player.src = s;

	// For good measure
	player.play();

	nowplaying.textContent = unescape(s);
	paintQueue();
	playing = true;
    } else {
	nowplaying.textContent = '';
	playing = false;
    }
}
................................................................................
	return false;
    }

    // Assemble full filename
    var fname = "/media" + path + "/" + pcontents.files[fidx]
    if (!playing) {
	player.src = fname;
	nowplaying.textContent = unescape(fname);
	player.play();
	playing = true;
    } else {
	playlist.push(fname);
	paintQueue();
    }
    return false;
................................................................................
function addAll() {
    if (pcontents.files.length > 0) {
	for (var fidx = 0; fidx < pcontents.files.length; fidx++) {
	    go_file(fidx);
	}
    }
}









// Push to dir
function go_dir(didx) {
    // Working on a previous click
    if (pcontents == null) {
	return false;
    }







>
>
>







 







|







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|

|
>







 







|







 







|







 







>
>
>
>
>
>
>
>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
...
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236

// Show the queue of tracks
var pqueue = document.getElementById("pqueue");

// Where to stash text of current track path
var trackname = document.getElementById("trackname");

// Text pane for what's playing
var nowplaying = document.getElementById("nowplaying");

// The playlist queue
var playlist = [];

// Current browsing path, and how "deep" we are down into it
var path = "";
var pdepth = 0;
// This will be path's contents; it goes to null while
................................................................................

    //
    // Paint file browsing window
    //
    res = ''

    // Name of active track in its own position
    trackname.textContent = do_trim(unescape(path));

    // Directories (if any)
    if (pcontents.dirs.length > 0) {
	res += '<b>Directories</b>:<br>';
	for (var didx = 0; didx < pcontents.dirs.length; didx++) {
	    d = pcontents.dirs[didx];
	    res += '<button onclick="return go_dir(' + didx.toString() + ');">'
................................................................................
	    res += '</button>' + unescape(f) + '<br>\n'
	}
    }

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

// Invert a path and make it friendlier to small screens
function do_trim(s) {
    var idx, elem, res = '';

    while (s.length > 0) {

	// Get next path element
	idx = s.lastIndexOf('/');
	if (idx == -1) {
	    elem = s;
	    s = '';
	} else {
	    elem = s.slice(idx+1);
	    s = s.slice(0,idx);
	}

	// Slash separator
	if (res.length > 0) {
	    elem = ' / ' + elem;
	}

	// Add it on
	res += elem;
    }
    return res;
}

// Update playlist queue pane
function paintQueue() {
    var f, res = '';
    for (var fidx = 0; fidx < playlist.length; fidx++) {
	f = do_trim(unescape(playlist[fidx]));
	res += f + '\n';
    }
    pqueue.textContent = res;
}

// For current path, get contents from web server
function curdir() {
    // Flag this op is pending
................................................................................
    if (playlist.length > 0) {
	var s = playlist.shift();
	player.src = s;

	// For good measure
	player.play();

	nowplaying.textContent = do_trim(unescape(s));
	paintQueue();
	playing = true;
    } else {
	nowplaying.textContent = '';
	playing = false;
    }
}
................................................................................
	return false;
    }

    // Assemble full filename
    var fname = "/media" + path + "/" + pcontents.files[fidx]
    if (!playing) {
	player.src = fname;
	nowplaying.textContent = do_trim(unescape(fname));
	player.play();
	playing = true;
    } else {
	playlist.push(fname);
	paintQueue();
    }
    return false;
................................................................................
function addAll() {
    if (pcontents.files.length > 0) {
	for (var fidx = 0; fidx < pcontents.files.length; fidx++) {
	    go_file(fidx);
	}
    }
}

// Clear the decks!
function dropAll() {
    if (playlist.length > 0) {
	playlist.length = 0;
	pqueue.textContent = '';
    }
}

// Push to dir
function go_dir(didx) {
    // Working on a previous click
    if (pcontents == null) {
	return false;
    }