Is it possible to pause and resume buffering of AVPlayer?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
AV player buffers the video in several cases, however no clear documentation on them. You can check currentItem.loadedTimeRanges to see what's going on more info can be found on this thread AVPlayer buffering, pausing notification, and poster frame
Yes it is possible to some extent!
You can use the playerItem's
preferredForwardBufferDuration
property to decide how much duration from the current playing time the player should prefetch. But sadly, this is only available from iOS version 10.Macro to check system version:
You can now set how much duration you want to prefetch (in seconds).
automaticallyWaitsToMinimizeStalling
is another property which enables theautoplay
orautowait
feature in avplayer. Because the player is likely to stall frequently if thepreferredForwardBufferDuration
is set to a smaller duration.You can also use the playeritem's
canUseNetworkResourcesForLiveStreamingWhilePaused
property to set if the player should continue or pause buffering when the player is in pause state. This is available from iOS 9 onwards.UPDATE - swift:
according to my test,
preferredForwardBufferDuration
should be greater or equal to 1.0,if it is below 1.0,default buffer duration will be used.