将特定时间的事件触发到MPMoviePlayerController播放的视频中(用于电影的自定义字幕) [英] Firing events at specific times into a video played by MPMoviePlayerController (for Custom Captions on Movie)
问题描述
我正在考虑实现SRT文件解析器,以将视频覆盖在MPMoviePlayerController类上.有人能想到一种在电影播放时在特定时间触发事件的可靠方法吗?
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?
推荐答案
嗯,对iOS的了解不如对AppKit的熟悉,但是看起来不像AppKit的NSTimer类直接对等.
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.
我想您总是可以使用CoreFoundation的CFTimer(位于CFRunLoop.h中)或NSObject的:-(void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay
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
例如:
[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];
这篇关于将特定时间的事件触发到MPMoviePlayerController播放的视频中(用于电影的自定义字幕)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!