AVAggregateAssetDownloadTask 不支持 currentRequest 属性

问题描述 投票:0回答:1

我正在尝试使用react-native本机模块在iOS中下载视频。相同的代码在独立的 iOS 应用程序中工作得很好,但在使用本机模块调用时会抛出错误。

错误-

Exception 'AVAggregateAssetDownloadTask does not support currentRequest property' was thrown while invoking downloadVideoUsingUri on target CacheVideoModule with params (
    "https://d14nfbmksdrc0w.cloudfront.net/Doctor_Strange_in_the_Multiverse_of_Madness_Official_Trailer/default.m3u8"
)
callstack: (
    0   CoreFoundation                      0x0000000193984e44 42CCFC7B-FF32-3D25-8F01-CCB2AD843A8B + 40516
    1   libobjc.A.dylib                     0x000000018cb1b8d8 objc_exception_throw + 60
    2   CFNetwork                           0x0000000194c820dc _CFNetworkErrorGetLocalizedDescription + 353964
    3   ExoPlayPOC                          0x00000001052521a0 __55+[FLEXNetworkObserver injectIntoNSURLSessionTaskResume]_block_invoke_2 + 52
    4   ExoPlayPOC                          0x0000000105780ec4 $s18react_native_video23AssetPersistenceManagerC14downloadStream3foryAA0D0C_tF + 1280
    5   ExoPlayPOC                          0x00000001057870a0 $s18react_native_video16CacheVideoModuleC08downloadE8UsingUriyySSF + 828
    6   ExoPlayPOC                          0x00000001057871ec $s18react_native_video16CacheVideoModuleC08downloadE8UsingUriyySSFTo + 60
    7   CoreFoundation                      0x00000001939ef6b4 42CCFC7B-FF32-3D25-8F01-CCB2AD843A8B + 476852
    8   CoreFoundation                      0x000000019399bb1c 42CCFC7B-FF32-3D25-8F01-CCB2AD843A8B + 133916
    9   CoreFoundation                      0x000000019399b534 42CCFC7B-FF32-3D25-8F01-CCB2AD843A8B + 132404
    10  ExoPlayPOC                          0x00000001053c136c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1744
    11  ExoPlayPOC                          0x00000001053c51b0 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1544
    12  ExoPlayPOC                          0x00000001053c49cc _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 144
    13  ExoPlayPOC                          0x00000001053c4930 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28
    14  libdispatch.dylib                   0x000000010850453c _dispatch_call_block_and_release + 32
    15  libdispatch.dylib                   0x0000000108505ff0 _dispatch_client_callout + 20
    16  libdispatch.dylib                   0x000000010850e0a0 _dispatch_lane_serial_drain + 988
    17  libdispatch.dylib                   0x000000010850edc8 _dispatch_lane_invoke + 420
    18  libdispatch.dylib                   0x000000010851bcac _dispatch_workloop_worker_thread + 740
    19  libsystem_pthread.dylib             0x00000001e1bfcdf8 _pthread_wqthread + 288
    20  libsystem_pthread.dylib             0x00000001e1bfcb98 start_wqthread + 8
)

代码-

// Create the configuration for the AVAssetDownloadURLSession.
let backgroundConfiguration = URLSessionConfiguration.background(withIdentifier: "AAPL-Identifier")
        
// Create the AVAssetDownloadURLSession using the configuration.
let assetDownloadURLSession = AVAssetDownloadURLSession(configuration: backgroundConfiguration, assetDownloadDelegate: self, delegateQueue: OperationQueue.main)

let _asset = AVURLAsset(url: URL(string: "https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8")!)
let preferredMediaSelection = _asset.preferredMediaSelection
guard let task =
   assetDownloadURLSession.aggregateAssetDownloadTask(with: _asset,
                                                      mediaSelections: [preferredMediaSelection],
                                                      assetTitle: "my asset",
                                                      assetArtworkData: nil,
                                                      options:
       [AVAssetDownloadTaskMinimumRequiredMediaBitrateKey: 265_000]) else { return }

task.taskDescription = "1"

task.resume()

这个错误没有太多内容。 https://github.com/facebook/flipper/issues/2507

我期待在使用它时出现此错误的一些建议或解决方案,在react-native中抛出本机模块。

ios download avplayer offline
1个回答
0
投票

这对我来说是因为 Flipper 它是一个用于在模拟器或物理设备上调试 React Native 项目的平台工具。它给了我与您在离线下载视频时遇到的相同错误。

我发现在 Podfile 中禁用

:flipper_configuration => FlipperConfiguration.disabled,
可以在调试和发布时为我解决这个问题。

这是一个关于鳍状肢的问题

© www.soinside.com 2019 - 2024. All rights reserved.