在特定时间将事件触发到 MPMoviePlayerController 播放的视频中(用于电影上的自定义字幕)

发布于 2024-09-30 22:53:52 字数 92 浏览 2 评论 0原文

我正在考虑实现一个 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫南 2024-10-07 22:53:52

嗯,我对 iOS 的熟悉程度不如 AppKit,但看起来并没有 AppKit 的 NSTimer 类的直接等价物。

我想你总是可以使用 CoreFoundation 的 CFTimer (在 CFRunLoop.h 中找到)或 NSObject 的: - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay

例如:

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

如果用户快进、快退或执行某些操作,您需要调用以下命令来取消任何计划事件的发生:

[NSObject cancelPreviousPerformRequestsWithTarget:self];

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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文