ios - What's the difference between playbackLikelyToKeepUp and AVPlayerItemStatusReadyToPlay? -
i'm trying understand how detect when player item can play again.
see below observer logic:
if (object == playeritem && [keypath isequaltostring:@"playbackbufferempty"]) { if (playeritem.playbackbufferempty) { // show loading indicator } } if (object == playeritem && [keypath isequaltostring:@"playbacklikelytokeepup"]) { if (playeritem.playbacklikelytokeepup) { // hide loading indicator if (playeritem.status == avplayeritemstatusreadytoplay) { // start playing } else if (playeritem.status == avplayerstatusfailed) { // handle failed } else if (playeritem.status == avplayerstatusunknown) { // handle unknown } } }
is checking avplayeritemstatusreadytoplay
underneath playbacklikelytokeepup
overkill?
or
should listen status
change on player item instead of bothering playbacklikelytokeepup
?
the 2 properties inform of 2 different pieces of information in regards status of avplayeritem. avplayeritemstatusreadytoplay
constant indicate readytoplay
once avplayer has been given sufficient time buffer enough of item's data such able begin playback of item. it. because item ready play, doesn't mean won't stall after first few seconds.
playbacklikelytokeepup
returns bool
indicating playback of item "likely" keep throughout duration of item. property not pertain beginning of item, avplayeritemstatusreadytoplay
. not "care" if item ready playback, "cares" wether or not "thinks" playback of item keep without stalling. prediction of playability takes account various factors can read here -> https://developer.apple.com/documentation/avfoundation/avplayeritemstatus
so in regards question, overkill check value of avplayeritemstatusreadytoplay
after you've checked playbacklikelytokeepup
... you. check both. want ensure first item ready play, meaning sufficient data has been buffered avplayer
in order begin playback. , want ensure playbacklikeytokeepup == true
can have degree of certainty user's media experience won't interrupted. if care knowing when item ready begin playback again, need check status
.
Comments
Post a Comment