AVPlayer / AVPlayerItem返回播放错误太慢

时间:2016-10-17 14:09:31

标签: ios swift avplayer avplayeritem

如果服务器上没有文件(或其他服务器错误),AVPlayer会返回错误5-10秒。我该如何设置超时?

样品:

    let assetKeys = ["playable", "tracks", "duration"]

    asset.loadValuesAsynchronouslyForKeys(assetKeys) {
        var loaded = false

        for assetKey in assetKeys {
            var error: NSError?
            let status = asset.statusOfValueForKey(assetKey, error: &error)

            loaded = status == .Loaded
        }

        if !loaded {
            // error in 5-10 sec
        }
    }

1 个答案:

答案 0 :(得分:0)

如果在ios9.0 +上。 检查AVPlayItem是否canUseNetworkResourcesForLiveStreamingWhilePaused是否为。