Sina Safari
Sina Safari

Reputation: 131

just_audio not working on ios flutter Unhandled Exception: (-11800) The operation could not be completed

I am trying to run the just_audio sample project from its own repository https://github.com/ryanheise/just_audio/tree/master/just_audio/example

It is working fine on android but when I clone the project using a mac and run it on the simulator it throws this error :

[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: (-11800) The operation could not be completed 
    #0      AudioPlayer._load (package:just_audio/just_audio.dart:778:9)
    <asynchronous suspension>
    #1      AudioPlayer._setPlatformActive.<anonymous closure> (package:just_audio/just_audio.dart:1346:28)
    <asynchronous suspension>

And this error pops up while I'm trying to call the audio URL for streaming using setUrl() method

I have also tried Editing Transport security as the documentation recommends

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsForMedia</key>
    <true/>
</dict>

Note

I have tried all the other packages available for ios for playing and streaming audio and none of them worked

Upvotes: 13

Views: 7950

Answers (8)

Richa Shah
Richa Shah

Reputation: 982

how can we handle [GETX] Info: _GetImpl Instance of '_GetImpl' runZonedGuarded: PlatformException(-11800, The operation could not be completed, {index: 0}, null) this in app? , i have music app , where I download and play songs , but when I update the app , this downloaded path exists but doest not work. is there any way I can handle this issue?

flutter: setMediaItemInQueue called playFromMediaId title isdownload path : Clap Your Hands true /var/mobile/Containers/Data/Application/E0A30141-D87A-4960-827F-A2C76E6DAD0E/Documents/download/dccd547ede95829b98af67adc8af1ec9.mp3 [GETX] Instance "MusicTrayController" with tag "MusicTrayController" has been initialized flutter: MusicTrayController onInit flutter: musicBottomSheetOption isDownload true [GETX] Info: _GetImpl Instance of '_GetImpl' runZonedGuarded: PlatformException(-11800, The operation could not be completed, {index: 1}, null)

Upvotes: 0

Mathis Fouques
Mathis Fouques

Reputation: 244

I'm answering here in case anyone has the same issue. In my case :

  • I'm using a file on the device (iOS). (I mean not in remote)
  • I'm retrieving the file, and saving it in a local database solution (Isar for me).
  • When I'm trying to load the file (with setFilePath or AudioSource.file), it prints the exact same error
  • The error came in my case from some transformation that the local database did.. EDIT : Seems that it comes more from iOS only with file_picker (still debugging...), but anyway :

=> to eventually debug this case if every other answers don't work :

Try to do the very simple test to know if the file you want to load does exist (with File().existsSync() )

Upvotes: 1

Khalid
Khalid

Reputation: 61

If you are using AudioEncoder.aacLc, then don't use 'aac' extension, but use 'm4a'.

Upvotes: 0

HFranco
HFranco

Reputation: 609

For me, the error was that I had configured bitRate equal to 25600, when I changed it to 32000, it worked correctly.

record.start(
    path: 'pathTo/file/audio.m4a',
    encoder: AudioEncoder.aacLc,
    bitRate: 25600, // <-- Error
    samplingRate: 44100,
    numChannels: 1,
);

record.start(
    path: 'pathTo/file/audio.m4a',
    encoder: AudioEncoder.aacLc,
    bitRate: 32000, // Works!
    samplingRate: 44100,
    numChannels: 1,
);

It also worked with 64000 and 128000.

Upvotes: 0

Andre Pena
Andre Pena

Reputation: 59406

In my case, I restarted the IOS simulator and it worked perfectly.

Upvotes: 7

Kevin Lin
Kevin Lin

Reputation: 97

Use 'test.m4a' instead of

File file = File('test.mp3');

Upvotes: -1

Zamorite
Zamorite

Reputation: 819

You might need to test just_audio on a real iOS device.

It seems like the exception only gets thrown on a Simulator. 🤔


Also, don't forget to allow arbitrary loads as shown here by Reham 🙌🏽

Upvotes: 2

Reham Alraee
Reham Alraee

Reputation: 159

If you wish to connect to non-HTTPS URLS, add the following to your Info.plist file:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsForMedia</key>
    <true/>
</dict>

Upvotes: 3

Related Questions