Question

I am successfully making a CMTime with following code:

endPoint = CMTimeMake([mp currentPlaybackTime], 1);

The current position, which originally was a float value, of the movie in my MPMoviePlayerController is given back as a CMTime in seconds, which is not bad.

But how I can get this position in e.g. in milli seconds? I played with the 'timescale' and set it to 10 and 100, but it didn't have an effect to the result.

Thank you in advance!

Was it helpful?

Solution

I’m not really sure what you want. Do you understand the logic behind CMTime?

1.0s = 1/1s  = CMTimeMake(1, 1)
0.1s = 1/10s = CMTimeMake(1, 10)
0.2s = 1/5s  = CMTimeMake(1, 5)
0.2s = 2/10s = CMTimeMake(2, 10)
…

In other words, CMTimeMake(a, b) is the time value a/b. Thus when you have a floating-point time value:

double time1 = 0.2;
// in ms, (0.2*1000)/1000 == 200/1000 == 0.2
CMTime time2 = CMTimeMake(time1*1000, 1000);

Maybe this is what you want?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top