简体   繁体   中英

How to pause/resume avplayer preload

我正在使用AVPlayer播放来自互联网的视频, 暂停/恢复播放时有没有办法暂停/恢复预加载视频?

One way to do that would be to save your AVURLAsset to a variable ( tempAsset = player.playerItem.asset ), and then replace the playerItem in your player with nil. When you are ready to play it again, you can create a new playerItem from the asset that you saved previously.

I have same problem and i used buffer limit to stop preloading in my code. This works for me.

You can also try setting buffer limit to stop preloading video when you click on Pause or Resume.

I hope this will help you.

The duration the player should buffer media from the network ahead of the playhead to guard against playback disruption.

player.currentItem?.preferredForwardBufferDuration

When you work with AVPlayerItem you can set time interval for the buffer. Example:

AVPlayerItem(). preferredForwardBufferDuration = TimeInterval(exactly: 100)!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM