I'm trying to play an audio file using Howler.JS on a Vue page. Due to the Chrome AudioContext policy issue, I decided to wait for user interaction which will fire a method to start playing the audio file. However, no audio is played. I've checked and confirmed that the method is running so it seems to be something wrong with the Howler.JS part of the code.
I'm running the page on Chrome 75.0.3770.100 (Official Build) (64-bit) on macOS Mojave 10.14.5 (18F132) with Vue.JS 2.6.10 and Howler.JS 2.1.2. I found this solution (have not tried it) Howler.js doesn't recognize src path to audio file but it is not applicable as vue-howler is unmaintained.
<script>
import { Howl, Howler } from 'howler';
export default {
name: 'Lobby',
data() {
return {
userInteracted: false,
}
},
methods: {
interacted: function () {
this.userInteracted = true
var sound = new Howl({
src: [require('../assets/waiting.mp3')]
});
sound.play();
}
}
};
</script>