Frage

Wenn ich mir die Netzwerkkonnektivität meines Mac ansehe, kann ich erkennen, dass ein Film immer noch gepuffert wird, selbst nachdem ich die Ansicht entfernt habe, auf der sich der AVPlayer befand.

Weiß jemand, wie man AVPlayer dazu zwingen kann, das Laden von Daten zu stoppen?

War es hilfreich?

Lösung 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.

Andere Tipps

Vielleicht ist es zu spät, diese Frage zu beantworten, aber ich habe gerade die gleiche Frage gelöst.Speichern Sie es einfach hier, falls jemand etwas braucht...

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

Es gibt keine Abbruchmethode AVPlayer Klasse, aber in AVPlayerItem Und AVAsset Klasse, es gibt sie!

PS: player hier ist AVPlayer Klasse, nicht AVQueuePlayer Klasse.

Ich hatte das gleiche Problem und diese Linie hat es gelöst ..

generasacodicetagpre.

Ich rufe auch die Funktion

an generasacodicetagpre.

wenn Asset mein generationstätiges Objekt in meiner Spieler-Handler-Klasse

ist

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top