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.97k stars 841 forks source link

Failed to set source when try to play audio on IOS PHYSICAL DEVICE #1783

Open fabiojansenbr opened 5 months ago

fabiojansenbr commented 5 months ago

Checklist

Current bug behaviour

Im getting this error when try to play audio on IOS only in a physical device. On simulator works fine.

Runner(Flutter)[4087] : DeviceFileSource(path: /var/mobile/Containers/Data/Application/387E8E16-458F-4F36-80AB-C2152228C985/Documents/audios/audio17120075.m4a), Apr 1 20:40:44 Runner(Flutter)[4087] : PlatformException(DarwinAudioError, Failed to set source. For troubleshooting, see https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, AVPlayerItem.Status.failed on setSourceUrl, null)<\M-b\M^@\M-

Expected behaviour

The audio should play properly

Steps to reproduce

  1. Execute flutter run on the code sample
  2. ...
  3. ...

Code sample

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

Affected platforms

iOS

Platform details

No response

AudioPlayers Version

5.2.1

Build mode

No response

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

MuhammedMohsen1 commented 4 months ago

did you find solution ?

divya-BV commented 4 months ago

Any update on this? i am also facing the same issue

novas1r1 commented 4 months ago

Same issue but with ByteSource: Flutter 3.19.5 audioplayers 6.0.0 iOS: 17.4

"PlatformException (PlatformException(DarwinAudioError, Failed to set source. For troubleshooting, see https://github.com/bluefireteam/audioplayers/blob/main/troubleshooting.md, AVPlayerItem.Status.failed on setSourceUrl: Unknown error, null))"

narendra-vaniya commented 4 months ago

I'm encountering the same error: PlatformException(DarwinAudioError, Failed to set source. For troubleshooting, see https://TROUBLESHOOTING_GUIDE, AVPlayerItem.Status.failed on setSourceUrl: Unknown error, null) This issue occurs when I attempt to play audio using BytesSource on iOS. Working on Android, but failing on iOS.

Flutter 3.19.6 audioplayers 6.0.0 iOS: 17.4

narendra-vaniya commented 4 months ago

@novas1r1 Have you found any solution?

novas1r1 commented 4 months ago

@narendra-vaniya nope, sorry. I switched to soundpool

Gustl22 commented 4 months ago

You may can add some files in order to have a chance to reproduce the problem. Best regards.

narendra-vaniya commented 4 months ago

@narendra-vaniya nope, sorry. I switched to soundpool

Thank @novas1r1

callmephil commented 1 week ago

I've found a solution, we must provide the mimeType.

Sample.

    await _audioPlayer.play(
      BytesSource(bytes, mimeType: 'audio/mp3'),
    );

It would be nice to handle this case directly within the BytesSource class if the mimeType is empty.