问题
I'm using AVKit to play a 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:
nw_endpoint_flow_copy_multipath_subflow_counts Called on non-Multipath connection
Edit:
I found that AVPlayer doesn't support youtube URL
回答1:
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.
回答2:
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.
To combat this while testing, I am either not turning on AVPlayer
or I am only buffering a short track.
To cut down on the number of errors try initing your AVPlayer
like so:
var avPlayer : AVPlayer = AVPlayer()
This may cut down the errors by 30%.
来源:https://stackoverflow.com/questions/58431840/using-an-avplayer-returns-a-non-multipath-connection-error