forked from datacompboy/WavPlayer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
113 lines (111 loc) · 3.56 KB
/
index.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
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
<html>
<head><title>WavPlayer - flash wav/au player for arbitrary samplerate and PCM/G711 codecs</title>
<script>
function getPlayer(pid) {
var obj = document.getElementById(pid);
if (obj.doPlay) return obj;
for(i=0; i<obj.childNodes.length; i++) {
var child = obj.childNodes[i];
if (child.tagName == "EMBED") return child;
}
}
function doPlay(fname) {
var player = getPlayer('haxe');
player.doPlay(fname);
}
function doStop() {
var player = getPlayer('haxe');
player.doStop();
}
var SoundLen = 0;
var SoundPos = 0;
var Last = undefined;
var State = "STOPPED";
var Timer = undefined;
function getPerc(a, b) {
return ((b==0?0.0:a/b)*100).toFixed(2);
}
function FileLoad(bytesLoad, bytesTotal) {
document.getElementById('InfoFile').innerHTML = "Loaded "+bytesLoad+"/"+bytesTotal+" bytes ("+getPerc(BytesLoad,BytesTotal)+"%)";
}
function SoundLoad(secLoad, secTotal) {
document.getElementById('InfoSound').innerHTML = "Available "+secLoad.toFixed(2)+"/"+secTotal.toFixed(2)+" seconds ("+getPerc(secLoad,secTotal)+"%)";
SoundLen = secTotal;
}
var InfoState = undefined;
function Inform() {
if (Last != undefined) {
var now = new Date();
var interval = (now.getTime()-Last.getTime())/1000;
SoundPos += interval;
Last = now;
}
InfoState.innerHTML = State + "("+SoundPos.toFixed(2)+"/"+SoundLen.toFixed(2)+" sec ("+getPerc(SoundPos,SoundLen)+"%)";
}
function SoundState(state, position) {
if (position != undefined) SoundPos = position;
if (State != "PLAYING" && state=="PLAYING") {
Last = new Date();
Timer = setInterval(Inform, 100);
Inform();
} else
if (State == "PLAYING" && state!="PLAYING") {
clearInterval(Timer);
Timer = undefined;
Inform();
}
State = state;
Inform();
}
function init() {
var player = getPlayer('haxe');
if (!player || !player.attachHandler) setTimeout(init, 100); // Wait for load
else {
player.attachHandler("progress", "FileLoad");
player.attachHandler("PLAYER_LOAD", "SoundLoad");
player.attachHandler("PLAYER_BUFFERING", "SoundState", "BUFFERING");
player.attachHandler("PLAYER_PLAYING", "SoundState", "PLAYING");
player.attachHandler("PLAYER_STOPPED", "SoundState", "STOPPED");
player.attachHandler("PLAYER_PAUSED", "SoundState", "PAUSED");
InfoState = document.getElementById('InfoState')
Inform();
}
}
</script>
</head>
<body bgcolor="#dddddd" onload="init()">
<a href="javascript:doPlay()">doPlay()</a>
<a href="javascript:doPlay('test.gsm')">doPlay('test.gsm')</a>
<a href="javascript:doPlay('test-vf-44100.au')">doPlay('test-vf-44100.au')</a>
<a href="javascript:doPlay('hl-78003330781-5627.au')">doPlay('hl-78003330781-5627.au')</a>
<a href="javascript:doStop()">doStop()</a>
<br/>
<div id="InfoFile"></div>
<div id="InfoSound"></div>
<div id="InfoState"></div>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="300"
height="20"
id="haxe"
align="middle">
<param name="movie" value="wavplayer.swf?gui=full&h=20&w=300&sound=test-vf-44100.au&"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="salign" value="lt" />
<param name="bgcolor" value="#dddddd"/>
<embed src="wavplayer.swf?gui=full&h=20&w=300&sound=test-vf-44100.au&"
bgcolor="#dddddd"
width="300"
height="20"
name="haxe"
quality="high"
align="middle"
scale="noscale"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"
/>
</object>
</body>
</html>