Question

Lorsque je regarde la connectivité réseau de mon Mac, je peux dire qu'un film est toujours en mémoire tampon même après avoir supprimé la vue sur laquelle se trouvait AVPlayer.

Est-ce que quelqu'un sait comment forcer AVPlayer à arrêter de charger les données ?

Était-ce utile?

La solution 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.

Autres conseils

Il est peut-être tard pour répondre à cette question, mais je viens de résoudre la même.Enregistrez-le ici au cas où quelqu'un en aurait besoin...

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

Il n'y a pas de méthode d'annulation dans AVPlayer classe, mais dans AVPlayerItem et AVAsset classe, il y en a !

PS : player Voici AVPlayer la classe, non AVQueuePlayer classe.

J'ai eu le même problème et cette ligne résolue ..

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

J'appelle aussi la fonction

asset?.cancelLoading()

où l'actif est mon objet AVURLAsset à l'intérieur de la classe de manuel de lecteur

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top