I use AVPlayer's -(id)addPeriodicTimeObserverForInterval: queue: usingBlock:
method to update UI up to playback progress. However, my progress bar never reaches end.
CMTime duration = self.player.currentItem.asset.duration;
float totalSeconds = (Float64)(duration.value * 1000) / (Float64)(duration.timescale);
NSLog(@"duration: %.2f", totalSeconds);
__weak __typeof(self) welf = self;
[self.player addPeriodicTimeObserverForInterval:CMTimeMake(10, 1000)
queue:NULL // main queue
usingBlock:^(CMTime time) {
float totalSeconds = (Float64)(time.value * 1000) / (Float64)(time.timescale);
NSLog(@"progress %f", totalSeconds);
}];
logs:
App[2373:792179] duration: 3968.00
hit play button
App[2373:792179] progress 0011.176
App[2373:792179] progress 0021.175
...
App[2373:792179] progress 3701.319
App[2373:792179] progress 3704.000
Should not I expect last number to be 3968.0
?
Audio is streamed from server.
Aucun commentaire:
Enregistrer un commentaire