mirror of https://bitbucket.org/ausocean/av.git
25 lines
730 B
JavaScript
25 lines
730 B
JavaScript
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)
|
|
|
|
var decoded = decode(Array.from(bytes))
|
|
|
|
console.log("playing file")
|
|
var player = new PCMPlayer({
|
|
encoding: '16bitInt',
|
|
channels: 1,
|
|
sampleRate: 48000,
|
|
flushingTime: 2000
|
|
});
|
|
player.feed(Uint8Array.from(decoded))
|
|
}
|
|
reader.onerror = error => reject(error)
|
|
reader.readAsArrayBuffer(input)
|
|
|
|
})
|
|
} |