Firing events at specific times into a video played by MPMoviePlayerController (for Custom Captions on Movie)

冷暖自知 提交于 2019-12-11 09:14:43

问题


I'm considering implementing an SRT File parser for overlaying videos over an MPMoviePlayerController class. Can anyone think of a reliable way to fire off events at very specific times while a movie's playing?


回答1:


Hmm, not as familiar with iOS as I am with AppKit, but doesn't look like there's a direct equivalent of AppKit's NSTimer class.

I suppose you could always use CoreFoundation's CFTimer (found in CFRunLoop.h), or NSObject's: - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay

For example:

[self performSelector:@selector(updateSubtitle:) withObject:nextSubtitle afterDelay:0.5];

If the user fast-forwards, or rewinds or something you'd want to call the following to cancel any scheduled events from happening:

[NSObject cancelPreviousPerformRequestsWithTarget:self];


来源:https://stackoverflow.com/questions/4131137/firing-events-at-specific-times-into-a-video-played-by-mpmovieplayercontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!