2019-07-23 11:27:03 +03:00
|
|
|
window.onload = function () {
|
|
|
|
|
|
|
|
document.getElementById('input').addEventListener('change', function () {
|
|
|
|
const input = event.target.files[0]
|
|
|
|
const reader = new FileReader()
|
|
|
|
|
|
|
|
reader.onload = event => {
|
|
|
|
bytes = new Uint8Array(event.target.result)
|
2019-07-23 07:58:43 +03:00
|
|
|
|
2019-07-23 11:27:03 +03:00
|
|
|
console.log("playing file")
|
|
|
|
var player = new PCMPlayer({
|
|
|
|
encoding: '16bitInt',
|
|
|
|
channels: 1,
|
|
|
|
sampleRate: 48000,
|
|
|
|
flushingTime: 2000
|
|
|
|
});
|
2019-07-24 10:42:24 +03:00
|
|
|
player.feed(bytes)
|
2019-07-23 11:27:03 +03:00
|
|
|
}
|
|
|
|
reader.onerror = error => reject(error)
|
|
|
|
reader.readAsArrayBuffer(input)
|
2019-07-23 07:58:43 +03:00
|
|
|
|
2019-07-23 11:27:03 +03:00
|
|
|
})
|
2019-07-18 09:34:50 +03:00
|
|
|
}
|