av/cmd/audio-player/main.js

30 lines
813 B
JavaScript
Raw Normal View History

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)
console.log(bytes.slice(0, 16))
var decoded = decode(bytes)
console.log("playing file")
console.log(decoded.slice(0, 16))
// var player = new PCMPlayer({
// encoding: '16bitInt',
// channels: 1,
// sampleRate: 48000,
// flushingTime: 2000
// });
// player.feed(bytes)
}
reader.onerror = error => reject(error)
reader.readAsArrayBuffer(input)
})
2019-07-18 09:34:50 +03:00
}