Reputation: 391
I have a game in which user clicks start button and after that by setInterval program randomly chooses an audio from an array and plays it. It works fine everywhere but safari. I've also tried to use a ResponsiveVoice API. None of them works. It looks as the code below:
var audio = new Audio();
audio.src = 'blabla';
and when user clicks start:
setInterval(function() {
audio.play();
}, 2000);
How can I solve this problem?
Upvotes: 2
Views: 2163
Reputation: 28553
If your audio file isn't working AT ALL in safari, (not just with the setInterval js), then it's probably the file type that is the problem.
Currently, flac and ogg audio types are not supported in Safari, but are in other browsers. Likewise with Opus, another open-source file type.
MP3 and AAC are the most widely supported file types, followed by .wav The use of web audio is pretty widely supported also.
Refer to caniuse for more info.
Upvotes: 1