-
Notifications
You must be signed in to change notification settings - Fork 8
/
player.html
executable file
·79 lines (74 loc) · 6.74 KB
/
player.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
35
36
37
38
39
40
41
42
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
<html>
<header>
<style type="text/css"> <!-- a {text-decoration:none; color:#C0C0C0;} a:hover {text-decoration:underline;} --></style>
<script type="text/javascript" src="jsSID.js"></script>
<script type="text/javascript"> //included in jsSID version: 0.9.1
var playstate=0; advance=1; var tuneid=0; var st=0; //these can be initialized differently if you want different startup
var URLlist=[]; var namelist=[]; var lengthlist=[]; var subtlist=[];
plreq = new XMLHttpRequest(); plreq.open('GET','playlist.txt',true); plreq.overrideMimeType('text/plain; charset=x-user-defined'); //plreq.responseType="arraybuffer";
plreq.onload = function() { var playlist = plreq.responseText.split('\n'); //.match(/^.*([\n\r]+|$)/gm); //parse text into lines
URLlist.length=0; namelist.length=0; lengthlist.length=0; subtlist.length=0;
for (var i=0; i<playlist.length && playlist[i].length>2; i++) { URLlist.push( playlist[i].substr(0,playlist[i].lastIndexOf('.sid')+4) );
var p=playlist[i].lastIndexOf('/')+1; namelist.push( playlist[i].substr(p,playlist[i].lastIndexOf('.')-p) );
var minsec = playlist[i].substr(playlist[i].lastIndexOf('.sid')+4).split(':');
lengthlist.push( parseInt(minsec[0])*60+parseInt(minsec[1]) ); if(parseInt(minsec[2])) subtlist.push( parseInt(minsec[2]-1) ); else subtlist.push(0);
var listanchor = document.createElement('a'); listanchor.href=URLlist[i]; listanchor.id=i; listanchor.onclick=selectune;
var listelement = document.createElement('li'); listanchor.innerHTML=namelist[i].substr(0,32)+(namelist[i].length>32?'..':'');
var listsubt = document.createElement('span'); listsubt.style.fontSize='9pt'; listsubt.style.color='#506060';
listsubt.innerHTML = subtlist[i]? ' / '+parseInt(subtlist[i]+1)+' ' : '';
var listtime = document.createElement('span'); listtime.style.fontSize='9pt'; listtime.style.color='#506070';
listtime.innerHTML = lengthlist[i]? ' ('+parseInt(minsec[0])+':' + (minsec[1]<10?'0':'') + parseInt(minsec[1])+')' : '';
listelement.appendChild(listanchor); listelement.appendChild(listsubt); listelement.appendChild(listtime); document.getElementById('playlistui').appendChild(listelement);
if(playstate) loadtune(tuneid); }
}; plreq.send();
SIDplayer = new jsSID(16384,0.0005); SIDplayer.setloadcallback(loadcb); SIDplayer.setstartcallback(startcb); setInterval('show_playtime()',100);
function selectune() { tuneid=this.id; loadtune(tuneid); return false; }
function loadtune(num) { st=subtlist[num]; SIDplayer.setendcallback(advance?nextune:null,lengthlist[num]); SIDplayer.loadstart(URLlist[num],st); playstate=1;
document.getElementById('titledisp').innerHTML=namelist[num].substr(0,16) + (namelist[num].length>16?'..':'');
show_playlength(num); num++; document.getElementById('numdisp').innerHTML = num+'.'; }
function loadcb() { st=subtlist[tuneid]; document.getElementById('subtdisp').innerHTML = SIDplayer.getsubtunes();
document.getElementById('infodisp').innerHTML=SIDplayer.getauthor()+': '+SIDplayer.gettitle()+' ('+SIDplayer.getinfo()+') ';
document.getElementById('prefmodeldisp').innerHTML='('+SIDplayer.getprefmodel()+')'; startcb(); }
function startcb() { playstate=1; document.getElementById('selsubt').innerHTML = st+1; document.getElementById('playpause').innerHTML='||'; }
function show_playtime() { document.getElementById('playtimedisp').innerHTML=parseInt(SIDplayer.getplaytime()/60)+':' + ((SIDplayer.getplaytime()%60)<10?'0':'') + parseInt(SIDplayer.getplaytime()%60); }
function show_playlength(num) { document.getElementById('lengthdisp').innerHTML = (lengthlist[num] && st==subtlist[num])? '/'+parseInt(lengthlist[num]/60)+':'+ ((lengthlist[num]%60)<10?'0':'') + parseInt(lengthlist[num]%60) : ''; }
function show_advance() { document.getElementById('autoadvdisp').innerHTML = (advance?'ON':'OFF'); }
function nextune() { if(!advance||st!=subtlist[tuneid])return; if(++tuneid>=namelist.length) tuneid=0; loadtune(tuneid); document.getElementById(tuneid).focus(); } //document.getElementById(tuneid).click(); }
</script>
</header>
<body bgcolor="#000000" text="#CCCCCC" style="margin:20px;font-family:sans-serif;font-size:11pt"
onload="document.getElementById('volslider').value=1;show_advance();" onbeforeunload="SIDplayer.stop();">
<center>
<table id="playerui" bgcolor="#304040" width="460px" border="0" style="padding:6px;">
<tr><td><table border="0" style="white-space:nowrap;">
<td id="numdisp">.</td>
<td id="titledisp" align="center" bgcolor="#202020" width="100%" style="overflow:hidden;">...</td>
<td id="prefmodeldisp" style="padding-left:5;"> </td>
<td style="padding-left:5;"> <span id="selsubt">1</span>/<span id="subtdisp">1</span> </td>
<td> <span id="playtimedisp" style="padding-left:5;">00:00</span><span id="lengthdisp"></span> </td>
</table></td></tr>
<tr><td> <marquee style="font-size:9pt;" id="infodisp" behavior="alternate" scrollamount="2">...</marquee> </td></tr>
<tr><td align="center" style="white-space:nowrap;">
<button class="ctrl" id="playpause" style="width:30px;" onclick="if (playstate) {SIDplayer.pause();playstate=0;this.innerHTML='>';} else {SIDplayer.playcont();playstate=1;this.innerHTML='||';}">></button>
<button class="ctrl" onclick="SIDplayer.stop();playstate=0;document.getElementById('playpause').innerHTML='>';">stop</button>
<button class="ctrl" onclick="if(st<SIDplayer.getsubtunes()-1) SIDplayer.start(++st);playstate=1; show_playlength(tuneid);">subtune +</button>
<button class="ctrl" onclick="if(st>0) SIDplayer.start(--st); playstate=1; show_playlength(tuneid);">subtune -</button>
<button class="ctrl" onclick="if(SIDplayer.getmodel()==8580) SIDplayer.setmodel(6581); else SIDplayer.setmodel(8580);this.innerHTML=SIDplayer.getmodel();">8580</button>
<input class="ctrl" id="volslider" type="range" min="0" max="0.9" value="100" step="0.1" style="margin:0px;width:60px;vertical-align:middle;"
oninput="SIDplayer.setvolume(Math.log(1-value)/-2.3);" onchange="SIDplayer.setvolume(Math.log(1-value)/-2.3);">
</input>
</td></tr>
<tr><td bgcolor="#101010"> <ol id="playlistui" style="height:400px; overflow:hidden; overflow-y:scroll; list-style:normal; margin:2px; white-space:nowrap;">
<!--playlist is populated by javascript code-->
</ol> </td></tr>
<tr><td bgcolor="#203030"><table border="0" width="100%">
<tr>
<!-- <td> <input type="file" multiple="multiple" style="width:120px;"></input> </td> -->
<td> <button onclick="advance^=1; show_advance();">AutoAdvance</button><span id="autoadvdisp"></span> </td>
<td align="right" style="vertical-align:bottom;font-size:8pt;">
<a href="http://hermit.sidrip.com" target="blank">jsSID player by Hermit</a> </td> </tr>
</table></td></tr>
</table>
</center>
</body>
</html>