AVPlayerがデータを読み込むのを停止しないのはなぜですか?
質問
私の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.