window.onload = function () { document.getElementById('input').addEventListener('change', playFile) } function playFile() { const input = event.target.files[0] const reader = new FileReader() reader.onload = event => playData(event.target.result) // desired file content reader.onerror = error => reject(error) reader.readAsArrayBuffer(input) // you could also read images and other binaries } function playData(array){ var data = new Uint8Array(array) console.log("playing file") var player = new PCMPlayer({ encoding: '16bitInt', channels: 1, sampleRate: 48000, flushingTime: 2000 }); player.feed(data) }