Struggling to autoplay previously cached mp3 audio on mobile iOS devices (Safari and Chrome)
In my development of an Angular 8 app, I encountered an issue where I am attempting to cache a few incoming audio mp3 files in an array of objects. The goal is to autoplay or play these audio files based on user actions. Surprisingly, this feature works flawlessly on desktop and Android platforms but fails on mobile iOS devices at times.
Essentially, I iterate through an array of objects retrieved from an API and cache the mp3 files using a forEach loop:
items.forEach(item => {
const audio = new Audio();
audio.src = urlString;
}
However, when caching is disabled and the API is called each time to play the sound, everything functions correctly on mobile iOS devices.
Does anyone have any suggestions on how to resolve this issue?
Implementing mobile iOS audio caching