سؤال

عندما أشاهد اتصال شبكة جهاز 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 الطبقة، هناك!

ملاحظة: 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