作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们使用 GPUImageMovie 解码嵌入掩码的 MP4 压缩视频。
如果用户在视频解码期间按下主页按钮的问题 - 应用程序因 OpenGL 陷阱而崩溃。 iOS 不允许在后台使用 OpenGL。
有什么方法可以让 GPUImageMovie 立即停止解码,包括视频线程?
最佳答案
您应该在处理电影的 View Controller 中监听 UIApplicationWillResignActiveNotification 和 UIApplicationWillEnterForegroundNotification:
// handles the user pressing the home or power button while the camera is onscreen
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didResignActive:)
name: UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(willEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
object:nil];
然后您应该添加适当的方法来响应通知:
-(void) didResignActive: (NSString *) notification {
//stop processing the movie
}
-(void) willEnterForeground: (NSString *) notification {
// start processing the movie
}
我很确定您可以通过调用 [movie startProcessing];
开始处理并使用 [movie endProcessing];
停止处理,但我并不肯定。
关于ios - 如何在 GPUImage 中立即停止解码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19903542/
我是一名优秀的程序员,十分优秀!