AVPlayerがデータを読み込むのを停止しないのはなぜですか?

StackOverflow https://stackoverflow.com//questions/22002261

  •  20-12-2019
  •  | 
  •  

質問

私の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クラスにはキャンセル方法はありませんが、AVPlayerItemおよびAVAssetクラスでは、

があります。

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