audioplayers
audioplayers copied to clipboard
PlatformException(AndroidAudioError, Failed to set source.
Checklist
- [X] I read the troubleshooting guide before raising this issue
- [X] I made sure that the issue I am raising doesn't already exist
Current bug behaviour
Unable to handle exceptions thrown by native code after timeout (30 seconds). Even native code is throwing this exception
AudioPlayers Exception: AudioPlayerException(
I/flutter (14893): UrlSource(url: https://carestratusdev.blob.core.windows.net/voicemail/2021/08/02/dd8e9379-cee9-4cac-8faa-6b948bcfb477.mp3?sv=2023-11-03&st=2024-05-07T06%3A56%3A50Z&se=2024-05-07T07%3A26%3A50Z&sr=b&sp=r&sig=F6wQwHVDhRaHE9YvWf5Ed6rUZmRTM047GWkZDL%2B1V1c%3D, mimeType: null),
I/flutter (14893): PlatformException(AndroidAudioError, Failed to set source. For troubleshooting, see: https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, MEDIA_ERROR_UNKNOWN {what:1}, MEDIA_ERROR_SYSTEM, null)
Expected behaviour
There should be a way to set Timeout and then handle exceptions in Flutter. If there is an error in play audio (wrong URL), I want to show the error to the user and update the UI accordingly.
Steps to reproduce
- Execute
flutter run
on the code sample - wait for 30 seconds (which is default timeout)
Code sample
Code sample
void playAudio() async {
String url = "https://carestratusdev.blob.core.windows.net/voicemail/2021/08/02/dd8e9379-cee9-4cac-8faa-6b948bcfb477.mp3?sv=2023-11-03&st=2024-05-07T06%3A56%3A50Z&se=2024-05-07T07%3A26%3A50Z&sr=b&sp=r&sig=F6wQwHVDhRaHE9YvWf5Ed6rUZmRTM047GWkZDL%2B1V1c%3D";
AudioPlayer audioPlayer = AudioPlayer();
/// reset values on completion
audioPlayer.onPlayerComplete.listen((event) {});
/// Get current value
audioPlayer.onPositionChanged.listen((duration) {});
/// Get total duration
audioPlayer.onDurationChanged.listen((duration) {});
audioPlayer.play(UrlSource(url));
}
Affected platforms
Android, iOS
Platform details
- Platform 1: IOS 17.3
- Platform 2: Android 14
- Platform 3: M2 mac mini
AudioPlayers Version
6.0.0
Build mode
debug, profile, release
Audio Files/URLs/Sources
-
Url (Error) : https://carestratusdev.blob.core.windows.net/voicemail/2021/08/02/dd8e9379-cee9-4cac-8faa-6b948bcfb477.mp3?sv=2023-11-03&st=2024-05-07T06%3A56%3A50Z&se=2024-05-07T07%3A26%3A50Z&sr=b&sp=r&sig=F6wQwHVDhRaHE9YvWf5Ed6rUZmRTM047GWkZDL%2B1V1c%3D
-
Url (Working) : https://carestratusdev.blob.core.windows.net/voicemail/2024/01/19/86ac3aee-4e06-4abe-9e06-765d858d3034.mp3?sv=2023-11-03&st=2024-05-07T07%3A42%3A14Z&se=2024-05-07T08%3A12%3A14Z&sr=b&sp=r&sig=vkOpyl%2B4viiIOWD2NV3ViotTUHtOn5qSW%2F%2F6c2RV1jQ%3D
Screenshots
Logs
Code block with 2-3 relevant log lines
I/flutter (14893): AudioPlayers Exception: AudioPlayerException(
I/flutter (14893): UrlSource(url: https://carestratusdev.blob.core.windows.net/voicemail/2021/08/02/dd8e9379-cee9-4cac-8faa-6b948bcfb477.mp3?sv=2023-11-03&st=2024-05-07T06%3A56%3A50Z&se=2024-05-07T07%3A26%3A50Z&sr=b&sp=r&sig=F6wQwHVDhRaHE9YvWf5Ed6rUZmRTM047GWkZDL%2B1V1c%3D, mimeType: null),
I/flutter (14893): PlatformException(AndroidAudioError, Failed to set source. For troubleshooting, see: https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, MEDIA_ERROR_UNKNOWN {what:1}, MEDIA_ERROR_SYSTEM, null)
E/flutter (14893): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception:
Full Logs
E/MediaPlayerNative(14893): error (1, -2147483648)
E/MediaPlayer(14893): Error (1,-2147483648)
I/flutter (14893): AudioPlayers Exception: AudioPlayerException(
I/flutter (14893): UrlSource(url: https://carestratusdev.blob.core.windows.net/voicemail/2021/08/02/dd8e9379-cee9-4cac-8faa-6b948bcfb477.mp3?sv=2023-11-03&st=2024-05-07T06%3A56%3A50Z&se=2024-05-07T07%3A26%3A50Z&sr=b&sp=r&sig=F6wQwHVDhRaHE9YvWf5Ed6rUZmRTM047GWkZDL%2B1V1c%3D, mimeType: null),
I/flutter (14893): PlatformException(AndroidAudioError, Failed to set source. For troubleshooting, see: https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, MEDIA_ERROR_UNKNOWN {what:1}, MEDIA_ERROR_SYSTEM, null)
E/flutter (14893): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(AndroidAudioError, Failed to set source. For troubleshooting, see: https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, MEDIA_ERROR_UNKNOWN {what:1}, MEDIA_ERROR_SYSTEM, null)
E/flutter (14893):
E/flutter (14893): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(AndroidAudioError, Failed to set source. For troubleshooting, see: https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, MEDIA_ERROR_UNKNOWN {what:1}, MEDIA_ERROR_SYSTEM, null)
E/flutter (14893):
V/MediaPlayer(14893): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(14893): cleanDrmObj: mDrmObj=null mDrmSessionId=null
V/MediaPlayer(14893): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(14893): cleanDrmObj: mDrmObj=null mDrmSessionId=null
Flutter doctor:
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.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 17.0.10+0-17.0.10b1087.21-11572160)
[✓] Connected device (6 available)
• Infinix X690B (mobile) • 055832508C002250 • android-arm64 • Android 10 (API 29)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 14 (API 34) (emulator)
• iPhone (mobile) • 00008020-00020CCC14BB002E • ios • iOS 17.4.1 21E236
• iPhone 13 Pro Max (mobile) • 9A44EAB2-9FE4-4ECB-B2AF-2AA9FB3F91E3 • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.119
[✓] Network resources
• All expected network resources are available.
• No issues found!
Related issues / more information
No response
Working on PR
no way
Hi there. Did you check out the log stream? https://github.com/bluefireteam/audioplayers/blob/main/getting_started.md#log-event
Best regards
Thanks for reference, I will look into this