I am currently able to record video to an AVCaptureMovieFileOutput
instance , yet I can't find any sources to learn from that have show how video playback is possible like snapchat/facebook/instagram are capable of producing.
Am I supposed to use the AVCaptureVideoPreviewLayer
, and if so how would I do so as I am able to successfully record to an AVCaptureMovieFileOutput
instance. A Solution or guidance to what is used would be very helpful!
Or Is it a specific controller, player etc? I have found the only play to be AVPlayerViewController
however it isn't a player that is free of buttons and progress bars.
func captureMovie(withDelegate delegate: AVCaptureFileOutputRecordingDelegate) {
if movieOutput.isRecording == false {
let connection = movieOutput.connection(withMediaType: AVMediaTypeVideo)
if (connection?.isVideoStabilizationSupported)! {
connection?.preferredVideoStabilizationMode = AVCaptureVideoStabilizationMode.auto
}
let device = activeInput.device
if (device?.isSmoothAutoFocusEnabled)! {
do {
try device?.lockForConfiguration()
device?.isSmoothAutoFocusEnabled = false
device?.unlockForConfiguration()
}
catch {
print("Error smooth auto focus")
}
}
let outputURL = tempURL()
movieOutput.startRecording(toOutputFileURL: outputURL, recordingDelegate: delegate)
} else {
stopRecording()
}
}
Since AVCaptureMovieFileOutput
is saving the movie to a file URL. We need to use AVPlayerViewController
or AVPlayerLayer
to play it.
The optimal solution for you would be play the video from outputURL
in AVPlayerViewController
and to hide the controls like button and progress bar use below property to set false
@property(nonatomic) BOOL showsPlaybackControls;
Check below links for more info