Video not play in Flutter iOS getting error
Asked Answered
H

7

13

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>
Haines answered 17/2, 2022 at 8:46 Comment(10)
Did you try on a real device? IOS simulators has a lot exceptions what it can do. Moreover we need more information about your code implementation. No one can suggest or help you just with that platformexception error.Chuckle
Yes I have check in real device same error I have added full code link drive.google.com/file/d/1amGVhtz0CrnG5ocbjWImW79-XYRlXguN/…Haines
github.com/flutter/flutter/issues/56665 please check this issue, there are some solutions. Hopefully one of the will work for youChuckle
this issue is still open on github:github.com/flutter/flutter/issues/56665Shaquana
video_player plugging version please?Shaquana
your link to code is not working, not allowing to open filesShaquana
Check again you can download code.Haines
@JasminSojitra https://mcmap.net/q/909356/-flutter-video-player-not-playing-in-ios/3778710 any help on this ?Royroyal
@AliPunjabi https://mcmap.net/q/909356/-flutter-video-player-not-playing-in-ios/3778710 any help on this ?Royroyal
Here is the solution: gist.github.com/codler/3906826Maidenly
H
6

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.

Haines answered 13/9, 2022 at 5:52 Comment(4)
My url https and i am running it on real device. still getting the issue. Works fine in androidRoyroyal
Can you please share your video URLHaines
its a rest api expecting authentication headers. I have added the requst and response headers in this question https://mcmap.net/q/909356/-flutter-video-player-not-playing-in-ios/3778710Royroyal
But how can that be the solution, when he explicitly allows http connections using NSExceptionAllowsInsecureHTTPLoads ? I mean we are searching for a solution that allows http connections.Manufacturer
S
1

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

Sibeal answered 2/6, 2023 at 4:25 Comment(3)
This url works, do you know what exactly is causing the issueJacksmelt
Try changing the version of Video Player @JacksmeltSibeal
I am already on the latest versionJacksmelt
M
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.

Maidenly answered 16/6, 2023 at 15:43 Comment(1)
Could you share how to add the gist? I don’t know where to startFetial
C
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);
Cypress answered 19/7, 2023 at 7:53 Comment(0)
D
-2

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.

Duplicator answered 2/9, 2022 at 14:41 Comment(0)
S
-3

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"
Shaquana answered 17/2, 2022 at 10:33 Comment(1)
Comments are not for extended discussion; this conversation has been moved to chat.Lempira
B
-4

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.

Baton answered 15/12, 2022 at 11:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.