-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.html
executable file
·84 lines (73 loc) · 9.93 KB
/
demo.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
<!DOCTYPE html>
<html>
<head>
<title>AMR decode/encode tests</title>
<script src="amrnb.js" defer></script>
</head>
<body>
<button id='armPalyId'>play</button>
<script>
function E(selector) {
return document.querySelector(selector);
}
E('#armPalyId').onclick = function() {
var base = 'IyFBTVIKPEUKmqCQyYHI6M5a1iFhNcAAMLALgghoAAUILUWXS/A8Hj6FtVhcAMHv\r\nsNeCdgaUoDHwjG2x0e/YLd6mPsE7gDwagog9PE4DweBr1Af8/V605dqcQBq2TCWQ\r\nCQE6PbygPCjZZ7Ky7gFh8zs6xnjol/JNzco+cUhaCL4yAKE92yA8HG6bMrLIAYHz\r\ndGU0o/DRkY4T6dMRTzg/3EFqAoNcADynHHSwRb0QR7B8r2yvrgWlofKrSX6KooZp\r\ng8ZPwshQPCh3GTpbLgCh7zVKoVjDXcGhRRUmizn7CbHrNTuc2wA8dQ0oku0qAaH2\r\n/ios/ELnAh8w2g7eLI5s3tEDlpHjoDzgqSk9ecQIQf59GPDABHvp2bUDMlYmXNc1\r\nap0NzBnQPDk3c6z+1AWh9aEKIiHkSssCN5X8nonxxKKARZ9z7eA82Ih6RIloAaH7\r\nacrw+7scEbf2BA4/b11kjVKxUIgZMDwkaFSiOZQHIef+CnxXyI5VTcTFa8bMtD2D\r\nYcPvgpKAPBqSejtAgAVh4+Ab2iR+0GSqtYpN8Y+HMXATdrbrTvA8PupfRjGiCQHp\r\nneqz/UEFBxyXGfByXrNEHA6DhkEQoDwaqJuBBtABofIF1kai3Ca49Jc2dBhOyzum\r\n6puWP8ugPB5uX5v7M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BRyDvHfyzl9z7N8PZlRsONobf4nCoDwGH6MneoxQiWPYnKgVqM0VBC5Mu6p1GFLp\r\nl4HAKcnAPAS2ximZAX2jyJXxjtB23czR0r2MazP/5AtYGMtqLDA8FXuUI6fgoyPI\r\n0gz+B/U38XXvMlpwaRevwMRZKKecYDwGJTQq+LYEg9mSTbZALA6Sh+YkIE3c/6Eg\r\nA3mRQ5XwPBY3hRu9JxeLUcEcioQaGznMbKbMOW8eWmbYR+KfrtA8BhEpG6KuFQH+\r\nyy3Z5p5WuRuqAlHPBe/HyIQLcW/XoDwIHX0ZypbxAe6VLT0lCvWZZggWnCMw4L2a\r\nion4f4AwPAYahCmc3+cFs6BsVBr8aQcsWXb+EwIu610NN8KDSmA8DjYRGZ9lnOtV\r\noDy6wi8tygcQCzGXgf4qs1SF0LDM4DwOKC8R4JaXQfzVDP1V/SgLWV3p/ZjhbEpl\r\nlBsUnr6QPAYXsUHK9lKB/ZO61iM7mxtIXwkLbj0RrZGZgTVYNJA8CD12CbTDYYH/\r\nWHzwGYcM+2tBtR6tpebSTaXTa4Bn8DwCOj4hyKkPIfDDuztqlRBGkJcom8g/dCCH\r\npHhondJwPAZAV3GWroVh+NXcSiNeBtsAX1r4se39QqwSsBu0ckA8BDYocZ+yhsH7\r\nBVz8aTePC7v2ShfUOSn8GMfiJ8k84DwOuG0pmdaPAeQ1/I1w/9I13gVprnUkR+9R\r\n7OnjvN9w';
var data = _base64ToArrayBuffer(base);
playAmrArray(data);
}
function _base64ToArrayBuffer(base64) {
base64 = base64.replace(new RegExp(/\s/g),'')
var binary_string = window.atob(base64);
var len = binary_string.length;
var bytes = new Uint8Array( len );
for (var i = 0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
return bytes;
}
var gAudioContext;
function getAudioContext() {
if (!gAudioContext) {
if(window.AudioContext) {
gAudioContext = new AudioContext();
} else {
gAudioContext = new window.webkitAudioContext();
}
}
return gAudioContext;
}
function playAmrArray(data) {
if(window.AudioContext) {
var samples = AMR.decode(data);
if (!samples) {
alert('Failed to decode!');
return;
}
playPcm(samples);
} else {
var context = getAudioContext();
context.decodeAudioData(data.buffer, function(buffer) {
playSound(context, buffer);
})
}
}
function playPcm(samples) {
var context = getAudioContext();
var buffer = context.createBuffer(1, samples.length, 8000);
if (buffer.copyToChannel) {
buffer.copyToChannel(samples, 0, 0)
} else {
var channelBuffer = buffer.getChannelData(0);
channelBuffer.set(samples);
}
playSound(context, buffer);
}
function playSound(context, buffer) {
var source = context.createBufferSource();
source.buffer = buffer;
source.connect(context.destination);
source.start();
}
</script>
</body>
</html>