在Flutter iOS中无法播放视频,出现错误

wr98u20j  于 2022-12-19  发布在  Flutter
关注(0)|答案(4)|浏览(506)

Flutter iOS中无法播放视频,出现错误未处理异常:PlatformException(视频错误,无法加载视频:操作停止,空,空)。在android中运行良好。请让我知道你是否有这个想法。
=〉使用视频播放器插头
=〉代码链接= https://drive.google.com/file/d/1amGVhtz0CrnG5ocbjWImW79-XYRlXguN/view?usp=sharing
视频= 143.244.137.15:8000/media/event/org_event_video/None/event_video_4pnqGxk.mp4
=〉信息列表

<?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>
uujelgoq

uujelgoq1#

在iOS上,我找到了这个问题的解决方案,URL需要是HTTPS,应用程序需要在设备上运行,而不是模拟器。

k3bvogb1

k3bvogb12#

我发现解决方案如下链接:https://github.com/flutter/flutter/issues/56665#issuecomment-1235279217
我没有将以下内容添加到Info.plist:

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

希望能有所帮助。

col17t5w

col17t5w3#

**try:**问题出在返回视频链接的API中,似乎在iOS上需要一个标头来指定要发送的字节范围。通过添加此标头,视频将按预期工作。
降级您的插件或flutter/升级您的插件或flutter

编辑:添加到您的ios/Runner/info.plist

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

编辑:允许不安全的连接
1.转到您的xcode
1.转到ios/runner/信息列表
1.在右侧面板将有键,类型和值选项卡
1.转到信息属性列表/应用程序传输安全设置/例外域/您的域

  1. NS例外允许不安全HTTP负载
    1.允许“是”
e37o9pze

e37o9pze4#

我也有同样的问题。解决方法很简单。我的视频不能在手机上播放。它没有正确编码。当我正确编码后,问题就解决了。

相关问题