ios - AVPlayerItemDidPlayToEndTimeNotification is posted when the item did not finish playing -
i using avplayer playing tracks web. in playlist there several tracks. so, define action taken when current track reaches end, utilize kvo mechanism , register observer avplayeritemdidplaytoendtimenotification posted.
if (_player.currentitem.status == avplayeritemstatusreadytoplay) { [self play]; [nsnotificationcenter defaultcenter] addobserver:self selector:@selector(itemreachedend:) name:avplayeritemdidplaytoendtimenotification object:_player.currentitem]; }
when notification posted itemreachedend method called:
- (void) itemreachedend:(nsnotification *) notification { dispatch_async(dispatch_get_main_queue(), ^{ //switching next track }
the thing is, method called when item has not yet finished playing , have current track switched before has played end. not understand why happening.
please, tell me, doing wrong? maybe need take consideration other avplayeritem properties before track switching?
upd: have explored current position of current track not equal current track duration. why player thinks current item has finished playing?
not real reply question, have looked avqueueplayer
? should want without need switch track manually.
edit: sure notification current item? or maybe have observer played item around gets triggered reason?
ios objective-c avplayer
No comments:
Post a Comment