audioplayers
audioplayers copied to clipboard
Error when putting the audios in cache in iOS. It makes them ring by caching them.
When putting a local file in cache, it is played automatically in iOS. (Later, the first call to the audio does not work, the following yes).
Full Description I have a loading page and I take advantage of that page to cache different local audios. On Android it caches them without problems, on iOS it plays them on the loading page all at once. On the next page, I make use of those audios. On Android they work perfectly, but on iOS, the first time I call the audio, it doesn't work. The second and subsequent times, yes.
Code to Reproduce
AudioPlayer _audioP1 = AudioPlayer(playerId: 'p1');
await _audioP1.setSource(AssetSource('audio/p1.wav'));
Log Errors No errors displayed
Files/URLs/Sources https://drive.google.com/file/d/1yi93l_PaUEvbtuN3uqaNahU-xvT1LH0n/view?usp=sharing
Platforms The problematic platform is iOS. On Android it works as expected. On the first page it caches it, on the second page it plays it every time it is called.
Flutter Doctor
[✓] Flutter (Channel stable, 3.0.4, on macOS 12.4 21F79 darwin-x64, locale es-ES)
• Flutter version 3.0.4 at /Volumes/externo/cubel/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 85684f9300 (2 weeks ago), 2022-06-30 13:22:47 -0700
• Engine revision 6ba2af10bb
• Dart version 2.17.5
• DevTools version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Volumes/externo/cubel/SDK_ANDROID
• Platform android-33, build-tools 33.0.0
• Java binary at: /Volumes/externo/Aplicaciones/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Volumes/externo/Aplicaciones/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.67.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (3 available)
• iPhone 13 Pro Max (mobile) • 85EF168C-8273-4810-9076-7CC5E005E570 • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 12.4 21F79 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 103.0.5060.114
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
I have something like this happening to me as well for iOS / and MacOS. I am using some audiopool in my onload method and it will play all the sounds at once when I first load my flame game.
Same for me, as soon as I moved to flame_audio: 1.3.0
(which uses audioplayers 1.0.0
), I also started facing this issue.
• iPhone 11 Pro (mobile) iOS-15-5
+1 for this issue on iOS using audioplayers version 1.0.1 on recent iOS devices (14.x+) including Simulators.
Once .setSourceAsset
is called, sound is immediately played from device.
static const soundFolder = "assets/sounds/";
final AudioCache cache = AudioCache(prefix: soundFolder);
final AudioPlayer player = AudioPlayer();
player.audioCache = cache;
player.setSourceAsset('some_sound.mp3');
Downgrading to audioplayers version 0.20.1 and using AudioCache
class, this issue is not present.
+1 for this issue on iOS, plugin version 1.0.1. Also present on version 1.0.0.
I worked around this by adjusting the volume before and after setting the source.
AudioPlayer player = AudioPlayer();
AudioCache.instance.prefix = "assets/sounds/selected/";
if (Platform.isIOS) {
await player.setVolume(0);
}
await player.setReleaseMode(ReleaseMode.stop);
await player.setSourceAsset("Simple_Button.wav");
if (Platform.isIOS) {
await player.setVolume(1);
}