使用IOS目的C概念
- (NSTimeInterval) playableDuration
{
// use loadedTimeRanges to compute playableDuration.
AVPlayerItem * item = _moviePlayer.currentItem;
if (item.status == AVPlayerItemStatusReadyToPlay) {
NSArray * timeRangeArray = item.loadedTimeRanges;
CMTimeRange aTimeRange = [[timeRangeArray objectAtIndex:0] CMTimeRangeValue];
double startTime = CMTimeGetSeconds(aTimeRange.start);
double loadedDuration = CMTimeGetSeconds(aTimeRange.duration);
// FIXME: shoule we sum up all sections to have a total playable duration,
// or we just use first section as whole?
NSLog(@"get time range, its start is %f seconds, its duration is %f seconds.", startTime, loadedDuration);
return (NSTimeInterval)(startTime + loadedDuration);
}
else
{
return(CMTimeGetSeconds(kCMTimeInvalid));
}
}
進口AVFoundation – NSDeveloper
我得到這個錯誤信息, 'Float64' 是無法轉換爲 'CMTime' –
爲什麼你再次轉換Float64到CMTime? – NSDeveloper