xcode 使用 AVPlayer 会返回“非多路径连接”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/58431840/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 11:03:10  来源:igfitidea点击:

Using an AVPlayer returns a "non-Multipath connection" error

swiftxcodeurlavplayerviewcontroller

提问by Alex Giatrakis

I'm using AVKit to play a youtube URL.

我正在使用 AVKit 播放 youtube URL。

I have this code inside a button action:

我在按钮操作中有此代码:

 @IBAction func trailerButtonAction(_ sender: Any) {
    guard let youtubeUrl = youtubeURL else { return }
    let player = AVPlayer(url: youtubeUrl)
    let playerViewController = AVPlayerViewController()
    playerViewController.player = player

    present(playerViewController, animated: true) {
        player.play()
    }
}

The URL is valid, but when I press the button, the video doesn't stop loading and I'm getting this message on Debug area:

URL 有效,但当我按下按钮时,视频不会停止加载,我在调试区域收到此消息:

nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection

nw_endpoint_flow_copy_multipath_subflow_counts 在非多路径连接上调用

Edit:

编辑:

I found that AVPlayer doesn't support youtube URL

我发现 AVPlayer 不支持 youtube URL

回答by CMash

I would say this log isn't necessarily relevant. I was getting this error when trying to playback on the simulator but it wasn't happening on a real device.

我会说这个日志不一定相关。尝试在模拟器上播放时出现此错误,但在真实设备上没有发生。

回答by StarPlayrX

One workaround would be to use a 12.4.x simulator as it does not exhibit this issue. Only the 13.x simulators are showing this error. It happens to repeatedly that it slows down Simulator to a craw until all requested tracks have been buffered.

一种解决方法是使用 12.4.x 模拟器,因为它不会出现此问题。只有 13.x 模拟器显示此错误。碰巧它反复地减慢模拟器的速度,直到所有请求的曲目都被缓冲为止。

To combat this while testing, I am either not turning on AVPlayeror I am only buffering a short track.

为了在测试时解决这个问题,我要么没有打开,AVPlayer要么只是在缓冲一个短音轨。

To cut down on the number of errors try initing your AVPlayerlike so:

要减少错误数量,请尝试AVPlayer像这样初始化:

var avPlayer : AVPlayer = AVPlayer()

This may cut down the errors by 30%.

这可能会减少 30% 的错误。