just_audio
just_audio copied to clipboard
OGG File Cannot Open iOS Simulator [only]
I created this new bug report because previous issues have not been addressed I hope this clears up any confusion
- Issue #145 was closed without resolution because it was deemed to be an invalid bug report by @ryanheise . This pertained to an error playing local
ogg
files. - Open Feature Request #53 published on April 22, 2020 claimed there was support for
ogg
files with the new ExoPlayer but only for Android and no-one could verify at the time if there were issues with iOS. - Closed Pull Request #32 pertaining to
flac
support andogg
support did not mention issues in iOS.
Which API doesn't behave as documented, and how does it misbehave?
I replaced the original example file audio with a ogg
file however this did not play on my iOS Simulator but worked on Chrome and Android. However, when I tested mp3
and wav
files from Wikimedia servers I ran with no errors.
Minimal reproduction project REMOVED FOR PRIVACY PURPOSES
To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:
- Go to
await _player.setUrl();
- Change URL to
ogg
samplehttps://upload.wikimedia.org/wikipedia/commons/8/85/At_Valley_Forge_%28Champ_Clark%29.ogg
- Run Flutter on iOS Simulator
- See error
Error messages
[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: (-11828) Cannot Open
#0 AudioPlayer._load (package:just_audio/just_audio.dart:708:9)
<asynchronous suspension>
#1 AudioPlayer._setPlatformActive.<anonymous closure> (package:just_audio/just_audio.dart:1086:28)
<asynchronous suspension>
Expected behavior The button should load and be able to play the audio. Instead, the loading circle loops infinitely.
Desktop (please complete the following information):
- OS: MacOS Big Sur Version 11.2.3
- Browser: Chrome Version 89.0.4389.114 (Official Build) (x86_64)
Smartphone (please complete the following information):
- Device: Simulator iPhone 12
- OS: iOS 14.4
Flutter SDK version
[✓] Flutter (Channel stable, 2.0.2, on macOS 11.2.3 20D91 darwin-x64, locale en-PH)
• Flutter version 2.0.2 at /Users/REDACTED/Developer/flutter
• Framework revision 8962f6dc68 (4 weeks ago), 2021-03-11 13:22:20 -0800
• Engine revision 5d8bf811b3
• Dart version 2.12.1
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/REDACTED/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.53.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.19.0
[✓] Connected device (2 available)
• iPhone 12 (mobile) • 7BA42098-B278-4472-9B69-43554D46C7C6 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.114
Additional context
I tested multiple ogg
files to confirm that this is an issue with the format and not the specific file. In fact the file plays perfectly on Web and Android.
This is related to the underlying platform support for each codec. Not all codecs are supported by all devices, and Apple do not support OGG.
I am not sure if I would classify this as a bug, but we could consider it a feature request, and perhaps someone could theoretically add OGG support for iOS by manually decoding it in software. There would be libraries for doing that, but it is not necessarily an easy job.
An alternative would be to use an external transcoder (e.g. ffmpeg, if licensing permits) to convert the file before playback, then feed it into the player.
Another alternative for some apps where the audio in question is either packaged with the app or otherwise produced for the app, is to re-encode that audio with consideration of the codecs that are supported by each device you want to target. If that is not possible, another workaround is to have ffmpeg running on a server to do the transcoding.
I will change this to a feature request and leave open for someone who is interested to implement it.
Thank you very much @ryanheise! I checked the official iPhone forums and found the list of supported formats and true enough it does not include ogg
support.
Technically speaking you can play ogg
files on iOS devices using VLC (see WikiHow) so perhaps an implementation would be to use this.
Perhaps this can be added to the documentation instead? A list of supported file formats for different platforms?
Does ogg
really work on macOS as well?
i need a solution for this too
flutter: https://storage.googleapis.com/download/storage/v1/b/doc-app-static-site/o/1702044656589Recording.ogg?generation=1702044684514208&alt=media
flutter: https://storage.googleapis.com/download/storage/v1/b/doc-app-static-site/o/1702044656589Recording.ogg?generation=1702044684514208&alt=media
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: (-11828) Cannot Open
#0 AudioPlayer._load (package:just_audio/just_audio.dart:869:9)
this is my error on ios i cannot try a different format as my audio file is getting transcribed into text using chat GPT is there any easy fix???
i need a solution for this too
flutter: https://storage.googleapis.com/download/storage/v1/b/doc-app-static-site/o/1702044656589Recording.ogg?generation=1702044684514208&alt=media flutter: https://storage.googleapis.com/download/storage/v1/b/doc-app-static-site/o/1702044656589Recording.ogg?generation=1702044684514208&alt=media [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: (-11828) Cannot Open #0 AudioPlayer._load (package:just_audio/just_audio.dart:869:9) #1 AudioPlayer._setPlatformActive.setPlatform (package:just_audio/just_audio.dart:1464:28)
this is my error on ios i cannot try a different format as my audio file is getting transcribed into text using chat GPT is there any easy fix???
did u find any solution for this problem ?
As mentioned above, I recommend transcoding your file into a supported format via some other tool (such as ffmpeg if licensing permits) before using this plug-in to play it.