You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
973 B
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Opus to PCM</title>
</head>
<body>
<div id="container" style="width: 400px; margin: 0 auto;">
<h2>It should play audio if everying went well!</h2>
<p>However, the AudioContext may not allow starting the playing without a user gesture. Click this text to instruct the disobedient browser you really want to listen to the audio!</p>
</div>
<script>
window.onload = function() {
var socketURL = 'ws://localhost:8080';
var player = new PCMPlayer({
encoding: '16bitInt',
channels: 2,
sampleRate: 8000,
flushingTime: 2000
});
var ws = new WebSocket(socketURL);
ws.binaryType = 'arraybuffer';
ws.addEventListener('message',function(event) {
var data = new Uint8Array(event.data);
player.feed(data);
});
}
</script>
<script type="text/javascript" src="../pcm-player.min.js"></script>
</body>
</html>