bluefireteam / audioplayers

A Flutter package to play multiple audio files simultaneously (Android/iOS/web/Linux/Windows/macOS)
https://pub.dartlang.org/packages/audioplayers
MIT License
1.99k stars 843 forks source link

[Android] Audio not playing #1706

Open docaohuynh opened 10 months ago

docaohuynh commented 10 months ago

Checklist

Current bug behaviour

I run example code on actual device Oppo F1s (Android 6) but audio not playing I try using another lib just_audio it working

Expected behaviour

Audio playing on Oppo F1s

Steps to reproduce

  1. Execute flutter run on the example code

Code sample

Code sample ```dart void main() { } ```

Affected platforms

Android

Platform details

Android 6 device Oppo F1s

AudioPlayers Version

latest

Build mode

release

Audio Files/URLs/Sources

No response

Screenshots

No response

Logs

my relevant logs
Full Logs ``` my full logs or a link to a gist ``` Flutter doctor: ``` Output of: flutter doctor -v ```

Related issues / more information

No response

Working on PR

no way

Gustl22 commented 10 months ago

What audio are you playing? Can you state the source? Can you insert the logs plz? Thx :)

docaohuynh commented 10 months ago

@Gustl22 I run on example source https://github.com/bluefireteam/audioplayers/tree/main/packages/audioplayers/example It is not play any source at on. I was not seen logs in my device

docaohuynh commented 10 months ago

I found some error logs may it help

AudioLogLevel.error: AudioPlayers Exception: AudioPlayerException(
UrlSource(url: https://luan.xyz/files/audio/nasa_on_a_mission.mp3), 
PlatformException(AndroidAudioError, MEDIA_ERROR_UNKNOWN {what:-38}, MEDIA_ERROR_UNKNOWN {extra:0}, null)
AudioLogLevel.error: AudioPlayers Exception: AudioPlayerException(
AssetSource(path: nasa_on_a_mission.mp3), 
PlatformException(AndroidAudioError, MEDIA_ERROR_UNKNOWN {what:-38}, MEDIA_ERROR_UNKNOWN {extra:0}, null)
Gustl22 commented 10 months ago

Did you follow these steps: https://github.com/bluefireteam/audioplayers/blob/main/contributing.md#environment-setup ? So you use the latest version on branch main?

Does it work on your emulator?

I tried it right now and the source is playing without issues. I cannot reproduce it :/

docaohuynh commented 10 months ago

Did you follow these steps Yes So you use the latest version on branch main? Yes

@Gustl22 I had tested on 4 devices but this only happened on Oppo F1s (android 6)

My flutter doctor

[✓] Flutter (Channel stable, 3.13.7, on macOS 13.4 22F66 darwin-x64, locale en-VN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.84.2)
[✓] Connected device (2 available)
[✓] Network resources
Gustl22 commented 10 months ago

Thanks @docaohuynh, do these devices run all on Android 6? Maybe this can be solved via #1526. I don't think it's directly related to AudioPlayers but rather a fault in the Android native implementation.

docaohuynh commented 10 months ago

@Gustl22 Only Oppo F1s run Android 6 others Android 9, 12, 13. I don't have other device run on Android 6 to tested. waiting for ExoPlayer implement

arreshashikant commented 10 months ago

PlatformException(AndroidAudioError, MEDIA_ERROR_UNKNOWN {what:-38}, MEDIA_ERROR_UNKNOWN {extra:0}, null)

Happening on Pixel 4a, Android 13

[✓] Flutter (Channel stable, 3.13.9, on macOS 13.5.2 22G91 darwin-arm64, locale en-IN) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3)

audioplayers: ^5.2.0

BrunoJay commented 9 months ago

PlatformException(AndroidAudioError, MEDIA_ERROR_UNKNOWN {what:-38}, MEDIA_ERROR_UNKNOWN {extra:0}, null)

Happening on OS version: android13 Model:Galaxy S21 FE 5G

audioplayers: ^5.2.0

newproplus commented 9 months ago

I found the same issue.

OS version: android12 audioplayers version: 5.2.1

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.3, on Debian GNU/Linux 12 (bookworm) 6.1.0-15-amd64, locale zh_CN.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.85.0)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!
md-rifatkhan commented 7 months ago

Same problem

serg10andres commented 7 months ago

Same problem

Kind-Unes commented 5 months ago

any solutions ?

Gustl22 commented 5 months ago

The solution is probably #1691, but it takes a while for Flutter to review all the necessary PRs.

prajyotpdev commented 4 months ago

Previously my code was like : final audioPlayer = AudioPlayer(); audioPlayer.setSourceUrl("https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3"); I ran thorugh error : PlatformException(AndroidAudioError, Failed to set source. For troubleshooting

After sometime it trigggered as it was just async await issue of url. Since, url sends some data to audioplayer to play at first It need sometime to init and which was causing the error of playing on the first step itself. Simply putting "await" helped me !!

solved code:
final audioPlayer = AudioPlayer(); await audioPlayer.setSourceUrl("https://www.learningcontainer.com/wp-content/uploads/2020/02/Kalimba.mp3");