8

Video not play in Flutter iOS getting error Unhandled Exception: PlatformException(VideoError, Failed to load video: Operation Stopped, null, null). Working well in android. Please let me know if you have idea of this.

=>Using video_player plugging

=>Code link= https://drive.google.com/file/d/1amGVhtz0CrnG5ocbjWImW79-XYRlXguN/view?usp=sharing

Video=http://143.244.137.15:8000/media/event/org_event_video/None/event_video_4pnqGxk.mp4

=>Info.plist

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>Evento Package</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>evento_package</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>FirebaseAppDelegateProxyEnabled</key>
    <string>0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
        <string>remote-notification</string>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsForMedia</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>143.244.137.15:8000</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>
</dict>
</plist>
Jasmin Sojitra
  • 1,090
  • 10
  • 24

7 Answers7

2

On iOS, I found a solution to this problem. The URL needs to be HTTPS, and the app needs to be run on the device instead of the simulator.

Jasmin Sojitra
  • 1,090
  • 10
  • 24
0

Try this url https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8

It is working fine from my end on iOS

Kaival Patel
  • 461
  • 3
  • 8
0

There can be several solutions to the problem:

  1. HTTP issue - This problem can be resolved by setting NSAppTransportSecurity - NSAllowsArbitraryLoads - true. However, in my case, this was not the issue.

  2. Simulator issue - This problem can be resolved by using a physical device instead of a simulator. However, in my case, this was also not the issue.

  3. Data transmission issue on the server side:

By following these links, you'll find that the key is to add Content-Range to the header. In my case, I changed the way the server sends the video using the third solution, and it worked correctly.

I hope this answer helps many Flutter developers.

whdals0
  • 175
  • 1
  • 3
  • 21
0

In my case, the problem arose when I switched away from using the now-deprecated VideoPlayerController.network constructor:

String path = "https://example.com/myfile.mp4?alt=media&token=ab1-cd2";
var videoPlayerController = VideoPlayerController.network(path);

and switched to:

String path = "https://example.com/myfile.mp4?alt=media&token=ab1-cd2";
var uri = Uri(path: path); // problematic due to percent-encoding
var videoPlayerController = VideoPlayerController.networkUrl(uri);

My problem was actually with my new use of the default Uri constructor. uri contained percent encoding, which the VideoPlayer couldn't handle. (Eg: "https%3A//example.com/myfile.mp4%3Falt=media&token=ab1-cd2")

I got it working by instead using a different Uri constructor:

String path = "https://example.com/myfile.mp4?alt=media&token=ab1-cd2";
var uri = Uri.parse(path); // works correctly; has no percent-encoding
var videoPlayerController = VideoPlayerController.networkUrl(uri);
C. Swanson
  • 81
  • 1
  • 6
-1

I found the solution as below link: https://github.com/flutter/flutter/issues/56665#issuecomment-1235279217

And I didn't add below things to Info.plist:

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

I hope it can help.

-2

try: The problem is in the API returning video links, it seems like on iOS it needs a header to specify the range of the bytes to be sent. by adding this header the videos will work as expected.

or Downgrade your's plugin or flutter/ upgrade your's plugin or flutter

Edit: Add this to your ios/Runner/info.plist

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

Edit: Allow unsecure connections

  1. go to your xcode
  2. go to ios/runner/info.plist
  3. on the right side pannel there will be the key, type and value tab
  4. go to information property list/app transport security setting/exception domains/your domain
  5. NSExceptionAllowsInsecureHTTPLoads
  6. allow "yes"
Ali Punjabi
  • 452
  • 4
  • 19
  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/242198/discussion-on-answer-by-raja-ehtisham-video-not-play-in-flutter-ios-getting-erro). – Samuel Liew Feb 20 '22 at 15:05
-3

I have the same problem. And the solution was very simple. My video didn't play on my phone. It was not encoded correctly. When I right coded, the problem was solved.