嗨,我正在开发一个Flutter应用程序。在这个应用程序中,一些声音从我的网站下载并保存到本地文件存储。显示某些图片时播放。
这在Android手机上正常工作。但是我不能在IOS模拟器中这样做。我已经控制了文件是否正确下载。我已经看过模拟器文件和声音文件,所以它们被正确下载。我的演奏代码就是这样的。
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");
}
在这段代码中,程序在这一行等待,而不会转到下一行。await advancedPlayer.onPlayerCompletion.first;
我没有看到任何错误。
我已经打印了声音文件路径并控制它,它在文件存储中。音频文件格式为mp3。
在我的pubspec.yaml文件中,我尝试了0.17.4和0.16.2版本。我不能使用0.18.x版本(因为其他软件包不允许)
audioplayers: ^0.17.4
太谢谢你了
[✓] 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
1条答案
按热度按时间vnjpjtjt1#
点击iPhone SIM卡上的静音按钮打开和关闭对我来说很有效。