使用Swift录制和播放视频并将视频发送到服务器
Using Swift to record and playback video and sending the video to a server
我正在尝试为 IOS 8 编写一个应用程序。此应用程序将在 Swift 中编写。我看过一些用于捕获视频和播放视频的 Youtube 视频。看来我必须使用 AVKit 才能做到这一点。
捕获视频后,我希望能够将视频发送到服务器,以便该应用的其他用户可以访问它。
所以我的问题是如何让我的应用程序录制视频、将该视频发送到服务器,以及如何从该服务器播放视频。
录制视频:
func startCaptureVideoBlogFromViewController(viewcontroller: UIViewController, withDelegate delegate: protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>) -> Bool{
if (UIImagePickerController.isSourceTypeAvailable(.Camera) == false) {
return false
}
let cameraController = UIImagePickerController()
cameraController.sourceType = .Camera
cameraController.mediaTypes = [kUTTypeMovie as String]
cameraController.allowsEditing = false
cameraController.delegate = delegate
presentViewController(cameraController, animated: true, completion: nil)
return true
}
我正在尝试为 IOS 8 编写一个应用程序。此应用程序将在 Swift 中编写。我看过一些用于捕获视频和播放视频的 Youtube 视频。看来我必须使用 AVKit 才能做到这一点。
捕获视频后,我希望能够将视频发送到服务器,以便该应用的其他用户可以访问它。
所以我的问题是如何让我的应用程序录制视频、将该视频发送到服务器,以及如何从该服务器播放视频。
录制视频:
func startCaptureVideoBlogFromViewController(viewcontroller: UIViewController, withDelegate delegate: protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>) -> Bool{
if (UIImagePickerController.isSourceTypeAvailable(.Camera) == false) {
return false
}
let cameraController = UIImagePickerController()
cameraController.sourceType = .Camera
cameraController.mediaTypes = [kUTTypeMovie as String]
cameraController.allowsEditing = false
cameraController.delegate = delegate
presentViewController(cameraController, animated: true, completion: nil)
return true
}