9

I'm trying to run my Flutter application on iOS Simulator and I have found that video player throws the following exception on init:

[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: PlatformException(VideoError, Failed to load video: The operation could not be completed, null, null)

After some googling, I found that there could be several fixes for that:

  1. Upgrading flutter
  2. Downgrading vide_player to 2.2.3
  3. Configuring web server to support Range header

I am running the latest flutter version, also downgrading plugin didn't do pretty much anything. I made sure that web server does support Range header by playing video in a browser.

I have also checked network requests in flutter DevTools and it seems that network request is never made (looking at other API requests working fine).

Another note is that this problem does not happen on Android emulator/real device and video plays just fine.

What could cause this issue? Is there any possible way to enable more verbose logging to see what exactly causes the issue, or is there something I missing? Thanks for the help.

Additional information:

  • Flutter 2.6.0-12.0.pre.899 on master branch
  • Xcode 13 from AppStore
  • iOS 15 running on Simulator

Doctor summary:

[✓] Flutter (Channel master, 2.6.0-12.0.pre.899, on macOS 12.0.1 21A559
    darwin-arm, locale en-RU)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK
      components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup
      for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] VS Code (version 1.62.3)
[✓] Connected device (2 available)
pnzrfst1
  • 189
  • 2
  • 9

2 Answers2

0

I had the same problem before, iOS does not support "http" video source if you are using it. You can try a "https" URL. Or if you haven't any control over your video source url. You can use the Cloudflare worker can response HTTP to HTTPS for your video source. It's means proxy

secret
  • 742
  • 1
  • 7
  • 24
0

iOS

If you need to access videos using http (rather than https) URLs, you will need to add the appropriate NSAppTransportSecurity permissions to your app's Info.plist file, located in <project root>/ios/Runner/Info.plist. See Apple's documentation to determine the right combination of entries for your use case and supported iOS versions.

Try adding the NSAllowsArbitraryLoads key to true in the NSAppTransportSecurity dictionary in your Info.plist file.

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

Reference link: https://pub.dev/packages/video_player#ios

Dharam Budh
  • 515
  • 2
  • 9