jjzjj

addPeriodicTimeObserverForInterva

全部标签

ios - addPeriodicTimeObserverForInterval 调用额外时间

我有一个带有4秒视频的AVPlayer(NSTimeIntervalduration=CMTimeGetSeconds(self.playerItem.asset.duration)=4)。我想通过更改来更新UI:self.periodicTimeObserver=[self.playeraddPeriodicTimeObserverForInterval:CMTimeMake(1,1)queue:dispatch_get_main_queue()usingBlock:^(CMTimetime){[weakSelfcurrentTimeDidChange:CMTimeGetSecond

ios - 在 iOS AVPlayer 中,addPeriodicTimeObserverForInterval 似乎丢失了

我正在尝试设置AVPlayer.addPeriodicTimeObserverForInterval()。有人用过这个成功吗?我正在使用Xcode8.1、Swift3 最佳答案 接受的答案让人觉得您可以将返回值分配给局部变量并忽略它。但是根据doc,实际上重要的是保持对返回值和removeTimeObserver(_:)的强引用。Youmustmaintainastrongreferencethereturnedvalueaslongasyouwantthetimeobservertobeinvokedbytheplayer.Eac

IOS addPeriodicTimeObserverForInterval 触发太多次

我注意到我的应用发生了一件奇怪的事情。这是一个视频应用程序,使用AVFoundation类。我需要在给定时间触发一些事件。我放了一些代码然后评论它:/*Ipreparethemovieclip*/AVMutableComposition*composition=[[AVMutableCompositionalloc]init];NSBundle*bundle=[NSBundlemainBundle];NSDictionary*optionsDictionary=[NSDictionarydictionaryWithObject:[NSNumbernumberWithBool:YES]f

ios - AVPlayer的addPeriodicTimeObserverForInterval中的CMTime : callback never reaches item's duration

我使用AVPlayer的-(id)addPeriodicTimeObserverForInterval:queue:usingBlock:方法根据播放进度更新UI。但是,我的进度条永远不会结束。CMTimeduration=self.player.currentItem.asset.duration;floattotalSeconds=(Float64)(duration.value*1000)/(Float64)(duration.timescale);NSLog(@"duration:%.2f",totalSeconds);__weak__typeof(self)welf=self