当我看到我的mac的网络连接,我可以告诉一部电影仍然缓冲,即使我删除了有AVPlayer上的视图。

有谁知道如何强制AVPlayer停止加载数据?

有帮助吗?

解决方案 4

I figured it out.

When you want to stop an AVPlayerItem from loading, use AVQueuePlayer's removeAllItems and then re-initialize it.

  [self.avPlayer removeAllItems];
  self.avPlayer = [AVQueuePlayer playerWithURL:[NSURL URLWithString:@""]];
  self.avPlayer = nil;

This will stop the current item from loading -- it is the only way I found to accomplish this.

其他提示

也许现在回答这个问题已经很晚了,但我刚刚解决了同样的问题。保存在这里,以防有人需要。..

    [self.player.currentItem cancelPendingSeeks];
    [self.player.currentItem.asset cancelLoading];

没有取消方法 AVPlayer 类,但在 AVPlayerItemAVAsset 班,有!

PS: player 这里是 AVPlayer 类,而不是 AVQueuePlayer 类。

我有同样的问题,这条线解决了它。.

self.avPlayer?.replaceCurrentItem(with: AVPlayerItem(url: URL.init(string: "https://www.asdfasdfasdfasdfasdfasd.net/")!))

我也调用函数

asset?.cancelLoading()

资产是我的 AVURLAsset 我的播放器处理程序类内的对象

An AVPlayer is not a view. You may have "removed the view" but that does not mean you have removed or stopped the AVPlayer. I would guess that the way to do what you want is to destroy the AVPlayer itself.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top