开发者

Obj-C: Convert a video's current time(double) to frame(decimal)

开发者 https://www.devze.com 2023-01-20 13:46 出处:网络
My app plays a movie and I must keep track of, and interact with the playback time. I use the currentPlaybackTime property to grab a double value of the movie\'s playback time. I want to use this to t

My app plays a movie and I must keep track of, and interact with the playback time. I use the currentPlaybackTime property to grab a double value of the movie's playback time. I want to use this to trigger some if statements开发者_StackOverflow社区 at certain points, But first it would be really helpful if I could convert the value into a value with only 2 decimal places ss.ff where ss are the seconds and ff are the frames. There are 30 frames in a second so it would go 0.29 to 1.0.

Can anyone help me with this? Thanks!


int seconds = floor(currentPlaybackTime);
int frames = 30 * (currentPlaybackTime - seconds);
double transformedPlaybackTime = seconds + (frames/100.0);

Although I would just work with the individual int seconds and int frames and not make up a fake playback time with the frames as the decimal portion.

0

精彩评论

暂无评论...
验证码 换一张
取 消