我以秒爲單位獲得當前播放值,但我需要以毫秒爲單位。我試圖currentTime.value/currentTime.scale。但它沒有得到確切的價值。如何獲取當前播放時間,AVPlayer中的CMTime以毫秒爲單位?
CMTime currentTime = vPlayer.currentItem.currentTime; //playing time
CMTimeValue tValue=currentTime.value;
CMTimeScale tScale=currentTime.timescale;
NSTimeInterval time = CMTimeGetSeconds(currentTime);
NSLog(@"Time :%f",time);//This is in seconds, it misses decimal value double shot=(float)tValue/(float)tScale;
shotTimeVideo=[NSString stringWithFormat:@"%.2f",(float)tValue/(float)tScale];
CMTime currentTime = vPlayer.currentItem.currentTime; //playing time
CMTimeValue tValue=currentTime.value;
CMTimeScale tScale=currentTime.timescale;
NSTimeInterval time = CMTimeGetSeconds(currentTime);
NSLog(@"Time :%f",time);//This is in seconds, it misses decimal value
double shot=(float)tValue/(float)tScale;
shotTimeVideo=[NSString stringWithFormat:@"%.2f", (float)tValue/(float)tScale];
不了你做第二/ 1000? –
@ HariKrishnan.P你確定你用1000乘以秒?大聲笑我很困惑! IT應該是秒/ 1000 –
毫秒=秒/ 1000。它的權利之一。我錯誤地寫了 –