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

Viewed 1464

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

3 Answers

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>

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

Use 'test.m4a' instead of

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

Related