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.
20 lines
571 B
JavaScript
20 lines
571 B
JavaScript
//PCM Player : https://github.com/samirkumardas/pcm-player/blob/master/example/server/server.js
|
|
|
|
window.onload = function () {
|
|
var socketURL = 'ws://' + window.location.hostname + ':56780'
|
|
var player = new PCMPlayer({
|
|
encoding: '16bitInt',
|
|
channels: 2,
|
|
sampleRate: 48000,
|
|
flushingTime: 100
|
|
})
|
|
|
|
var ws = new WebSocket(socketURL)
|
|
ws.binaryType = 'arraybuffer'
|
|
ws.addEventListener('message', function (event) {
|
|
var data = new Uint16Array(event.data)
|
|
player.feed(data)
|
|
player.volume(1)
|
|
})
|
|
}
|