Checklist
Current bug behaviour
I have already reported this bug on the thread at another issue. I thought that it can be related to that issue, but I was told to create another issue. #1194 (comment)
Since version 4.0.0 when I provide custom context for iOS global configuration I get console-level errors about configuration problems. The same errors are present in crashlytics. I updated the plugin to version 5.0.0, but the error continues to occur.
Here is code that creates errors:
I tried every value for AVAudioSessionCategory, but without any results. The error disappears when AudioContextIOS context is not provided.
Expected behaviour
Crash do not appear
Steps to reproduce
- Execute
flutter run on the code sample
- ...
- ...
Code sample
Code sample
void initGlobalAudioSettings() {
const audioContext = AudioContext(
android: AudioContextAndroid(
isSpeakerphoneOn: true,
stayAwake: true,
contentType: AndroidContentType.music,
usageType: AndroidUsageType.assistanceSonification,
audioFocus: AndroidAudioFocus.gain,
),
iOS: AudioContextIOS(
category: AVAudioSessionCategory.soloAmbient,
options: [
AVAudioSessionOptions.allowBluetooth,
AVAudioSessionOptions.allowBluetoothA2DP,
AVAudioSessionOptions.defaultToSpeaker,
]
)
);
AudioPlayer.global.setAudioContext(audioContext);
}
Current pubspec.lock
audioplayers:
dependency: "direct main"
description:
name: audioplayers
sha256: "2f4c0da9b483b45695d01dc738e1597d7137ae40fc2fa702f13ccc10efc706a2"
url: "https://pub.dev"
source: hosted
version: "5.0.0"
audioplayers_android:
dependency: transitive
description:
name: audioplayers_android
sha256: "7f18bb6c7de01684444e8cba577e3c3aee0ec379897f62ad4b8259d1e22f8c61"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
audioplayers_darwin:
dependency: transitive
description:
name: audioplayers_darwin
sha256: "80e341e6b2b364420516f2707271ec47f63b9b22766aa7f7d484601190c316a7"
url: "https://pub.dev"
source: hosted
version: "5.0.0"
audioplayers_linux:
dependency: transitive
description:
name: audioplayers_linux
sha256: cca3f272c7186dd2e0025b8864e1413ac5e081d74b17e28b02ceb2df4c110235
url: "https://pub.dev"
source: hosted
version: "3.0.0"
audioplayers_platform_interface:
dependency: transitive
description:
name: audioplayers_platform_interface
sha256: "47eae55e99ced11589998cf27e4eaabf5b475a7bd8bea7516ee6c2536a2e1abf"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
audioplayers_web:
dependency: transitive
description:
name: audioplayers_web
sha256: "9f155590c6ba9ba469df637f4729264e4234dc3941ece4690dad63ffac19b5af"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
audioplayers_windows:
dependency: transitive
description:
name: audioplayers_windows
sha256: "8813b712ba919bb324bde5e3ba97edc81bface945953a54a3dea70b5608bcc70"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
Affected platforms
iOS
Platform details
Tested on emulator iPhone 12, 13, 14 and physical iPhone 13 pro. All devices up to date.
AudioPlayers Version
4.0.1 - 5.0.0
Build mode
No response
Audio Files/URLs/Sources
No response
Screenshots
No response
Logs
[as_client] AVAudioSession_iOS.mm:2191 Error: category option 'defaultToSpeaker' is only applicable with category 'playAndRecord'
[as_client] AVAudioSession_iOS.mm:2367 Failed to set category, error: -50
flutter: ----------------FIREBASE CRASHLYTICS----------------
flutter: PlatformException(DarwinAudioError, Error configuring global audio session: Error Domain=NSOSStatusErrorDomain Code=-50 "(null)", null, null)
flutter:
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
<asynchronous suspension>
If 'defaultToSpeaker' value is not provided then first line in logs regarding category option does not appear.
Full Logs
Flutter doctor:
[!] Flutter (Channel stable, 3.10.3, on macOS 13.4.1 22F82 darwin-arm64, locale en-GB)
• Flutter version 3.10.3 on channel stable at /Users/mlecznyu/fvm/versions/3.10.3
! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart-sdk/3.0.3/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/mlecznyu/fvm/versions/3.10.3. Consider adding /Users/mlecznyu/fvm/versions/3.10.3/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f92f44110e (8 weeks ago), 2023-06-01 18:17:33 -0500
• Engine revision 2a3401c9bb
• Dart version 3.0.3
• DevTools version 2.23.1
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/mlecznyu/Library/Android/sdk
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.3)
• Android Studio at /Applications/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.13+0-b1751.21-8125866)
[✓] VS Code (version 1.79.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 (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.4.1 22F82 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 115.0.5790.114
[✓] Network resources
• All expected network resources are available.
Related issues / more information
#1194, #1491
Working on PR
yeah
Checklist
Current bug behaviour
I have already reported this bug on the thread at another issue. I thought that it can be related to that issue, but I was told to create another issue. #1194 (comment)
Since version 4.0.0 when I provide custom context for iOS global configuration I get console-level errors about configuration problems. The same errors are present in crashlytics. I updated the plugin to version 5.0.0, but the error continues to occur.
Here is code that creates errors:
I tried every value for
AVAudioSessionCategory, but without any results. The error disappears whenAudioContextIOScontext is not provided.Expected behaviour
Crash do not appear
Steps to reproduce
flutter runon the code sampleCode sample
Code sample
Current pubspec.lock
Affected platforms
iOS
Platform details
Tested on emulator iPhone 12, 13, 14 and physical iPhone 13 pro. All devices up to date.
AudioPlayers Version
4.0.1 - 5.0.0
Build mode
No response
Audio Files/URLs/Sources
No response
Screenshots
No response
Logs
If 'defaultToSpeaker' value is not provided then first line in logs regarding category option does not appear.
Full Logs
Flutter doctor:
Related issues / more information
#1194, #1491
Working on PR
yeah