我正在尝试制作一个大冒险。目前我正在研究相机的录像部分。我拍了一段视频,制作了一个网址,然后设置MPMoviePlayerController
来播放它。将UITextField
添加到MPMoviePlayerController.view并保存整个内容。问题是,它与捕获静止图像不同,如下所示:
imageView.layer.addSublayer(captionField.layer)
UIGraphicsBeginImageContext(self.view.bounds.size)
imageView.layer.renderInContext(UIGraphicsGetCurrentContext())
image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
let library:ALAssetsLibrary = ALAssetsLibrary()
var orientation: ALAssetOrientation = ALAssetOrientation(rawValue: image.imageOrientation.rawValue)!
library.writeImageToSavedPhotosAlbum(image.CGImage, orientation: orientation, completionBlock: nil)
目前我有这个,它只保存视频而不保存uitextfield:
moviePlayer = MPMoviePlayerController(contentURL: outputFileURL)
player = moviePlayer!
player.view.frame = self.view.bounds
player.controlStyle = .None
player.repeatMode = .One
player.prepareToPlay()
player.scalingMode = .AspectFill
self.view.addSubview(player.view)
player.view.layer.addSublayer(captionField.layer)
UIGraphicsBeginImageContext(self.view.bounds.size)
player.view.layer.renderInContext(UIGraphicsGetCurrentContext())
UIGraphicsEndImageContext()
ALAssetsLibrary().writeVideoAtPathToSavedPhotosAlbum(outputFileURL, completionBlock: {
(assetURL:NSURL!, error:NSError!) in
if error != nil{
print(error)
} else {
self.resetButtons()
}
})
我认为会有一个等同于静止图像保存方式的视频,但是你没有保存MPMoviePlayerController
,在我的函数中它被称为“播放器”或者是player.view,但是播放器的URL,可以使用player.contentURL访问(很高兴知道,但在这种情况下,冗余)或outputFileURL。有没有人在过去使用任何基于相机的应用程序实现此功能?有谁知道如何实现这一目标?