Pergunta

Quando observo a conectividade de rede do meu Mac, posso dizer que um filme ainda está em buffer mesmo depois de remover a visualização que continha o AVPlayer.

Alguém sabe como forçar o AVPlayer a parar de carregar dados?

Foi útil?

Solução 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.

Outras dicas

Talvez seja tarde para responder a esta pergunta, mas acabei de resolver a mesma.É só salvar aqui caso alguém precise...

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

Não há método de cancelamento em AVPlayer classe, mas em AVPlayerItem e AVAsset classe, existem!

PS: player aqui está AVPlayer classe, não AVQueuePlayer aula.

Eu tive o mesmo problema e esta linha resolveu.

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

Eu também chamo a função

asset?.cancelLoading()

onde o ativo é meu AVURLAsset objeto dentro da minha classe manipuladora de jogadores

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top