iphone - AVPlayer set initial playback time iOS -


added kvo avplayer when play video queueplayer avplayer

[self.queueplayer addobserver:self forkeypath:@"status" options:0 context:null]; 

observer method:

-(void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context {   if ([keypath isequaltostring:@"status"]) {     if (self.queueplayer.status == avplayerstatusreadytoplay) {          nsinteger step = (nsinteger)(starttimeforvideo/0.04);         [self.queueplayer.currentitem stepbycount:step];          //cmtime seektime = cmtimemake(starttimeforvideo*timescale,timescale);         //if (cmtime_is_valid(seektime))          //  [self.queueplayer seektotime:seektime tolerancebefore:kcmtimepositiveinfinity toleranceafter:kcmtimepositiveinfinity];         //else         //  nslog(@"in valid time");          [self.queueplayer play];     } else if (self.queueplayer.status == avplayerstatusfailed) {         /* error encountered */     } } 

here starttimeforvideo intial playback time video

seektotime not working neither stepbycount

edit : values of object used in methods correct , though no luck

changes in kvo method queueplayer avplayer:

if (self.queueplayer.status == avplayerstatusreadytoplay)  {   //firstly make cmtime here starttimeforvideo float64 value in seconds   //get video's time scale cmtime has it.    int32_t timescale = self.queueplayer.currentitem.asset.duration.timescale   cmtime seektime=cmtimemakewithseconds(starttimeforvideo, timescale);   //use cmtime seektotime.    [self.queueplayer seektotime:seektime tolerancebefore:kcmtimezero toleranceafter:kcmtimezero]; } ............ 

edit : here kcmtimezero in both tolerance field exact location in seektotime: tolerancebefore: toleranceafter: method


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -