7

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

Sina Safari
  • 71
  • 1
  • 4

5 Answers5

5

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

Andre Pena
  • 56,650
  • 48
  • 196
  • 243
2

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>
Reham Alraee
  • 139
  • 8
2

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

cigien
  • 57,834
  • 11
  • 73
  • 112
Zamorite
  • 686
  • 9
  • 13
  • 1
    Thanks but this issue was on both simulator and real device, I solved it btw. the issue was because I was using a signed URL generated by AWS with a security level on top of it. So It did not contain the audio extension in the URL itself. as soon as I add the extension to the URL , problem solved. – Sina Safari Jan 10 '22 at 19:16
  • 1
    could your tell me how to add audio extension in URL itself, pleas – mohamed abu-ghazalla Mar 04 '22 at 01:19
  • 1
    Just wanted to add that for me it works even on **iOS Simulator**. (my issue was with `NSAllowsArbitraryLoads`) – Mitrakov Artem Oct 18 '22 at 17:39
0

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.

HFranco
  • 592
  • 6
  • 9
-1

Use 'test.m4a' instead of

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

Kevin Lin
  • 97
  • 2