Hi I am developing a flutter application. In this application some sounds are downloaded from my website and saved to the local file storage. It plays when some pictures are showed.
This works in Android phone properly. But I cannot do it in IOS Simulator. I have controlled whether the files are downloaded properly. I have looked simulator files and saw sound files, so they are properly downloaded. My playing sound code is like that.
Future play(File soundFile) async {
debugPrint("sound: play enter");
try {
await advancedPlayer.stop();
advancedPlayer.setReleaseMode(ReleaseMode.RELEASE);
if (soundFile != null) {
print(soundFile.uri);
advancedPlayer.play(soundFile.uri.toString(), isLocal: true);
await advancedPlayer.onPlayerCompletion.first;
debugPrint("sound: played");
// advancedPlayer.stop();
}
} catch (e) {
debugPrint("sound: error");
}
debugPrint("sound: play leave");
}
In this code the program waits in this line and not doesn't go to the next lines.
await advancedPlayer.onPlayerCompletion.first;
I don't see any errors.
I have printed sound file path and controlled it, it is in the file storage. Format of audio file is mp3.
In my pubspec.yaml file I have tried 0.17.4 and 0.16.2 versions. I cannot use 0.18.x versions(because other packages dont let me)
audioplayers: ^0.17.4
Thank you so much
[✓] Flutter (Channel stable, 2.0.4, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-TR)
• Flutter version 2.0.4 at /Users/varyok/flutter
• Framework revision b1395592de (2 weeks ago), 2021-04-01 14:25:01 -0700
• Engine revision 2dce47073a
• Dart version 2.12.2
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/varyok/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0, Build version 12A7209
! Xcode 12.0.0 out of date (12.0.1 is recommended).
Download the latest version or update via the Mac App Store.
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 49.0.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.55.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.21.0
[✓] Connected device (2 available)
• iPhone 11 (mobile) • EC15BA0B-9EA7-4FCB-9DD0-E7A6F8B30B95 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
• Chrome (web) • chrome • web-javascript • Google
Chrome 89.0.4389.128