How to record a video with avfoundation in Swift?

前端 未结 1 682
滥情空心
滥情空心 2021-01-30 09:48

I am trying to figure out how to record a video using AVFoundation in Swift. I have got as far as creating a custom camera but I only figured out how to take still pictures with

相关标签:
1条回答
  • 2021-01-30 10:02

    I have tried your code. When set a meaningful filePath, everything goes fine. Change your filePath like this and you will get the delegate methods invoked:

        let documentsURL = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)[0]
        let filePath = documentsURL.URLByAppendingPathComponent("temp")
    
        // Do recording and save the output to the `filePath`
        videoFileOutput.startRecordingToOutputFileURL(filePath, recordingDelegate: recordingDelegate)
    
    0 讨论(0)
提交回复
热议问题