I recently wrote a function that changes the source for an audio file using wavesurfer.js and then plays the song with the newly loaded audio file. While my code is currently functioning as intended, I can't help but feel there might be a more efficient approach to achieving the same result.
Below is the code snippet of the function in question:
changeAudioFile(i){
let newSong = 'Link to a different File'
this.ws.load(newSong);
setTimeout(() => {
this.ws.play()
}, 1000);
}