Open joshoconnor89 opened 8 years ago
We had a similar issue with less powerful devices - 5S and iPod Touches.
I disabled the next button and didn't enable it until the Pause completion handler - touch wood this has sorted the issue.
Yeah, that worked. Seems as if SCRecorder needs time to process the video after it is paused, hence the completion handler. Thank you!
I recommend using the delegate method didCompleteSegment
instead of the pause callback. This method is called AFTER each segment is saved to memory. Therefore, you know the segments are all treated before showing your button:
func recorder(recorder: SCRecorder, didCompleteSegment segment: SCRecordSessionSegment?, inSession session: SCRecordSession, error: NSError?) {
// Check that the segment is not nil
// This can occur if there was an error writing the file
// Or if the segment was too short
if segment != nil {
// TODO: Enable your play button here
}
}
Note that this delegate is the perfect place to deal with anything segment related, like making sure it is longer than the minimum length you may have set etc…
I have two screens, a "Capture Screen", and a "Preview Capture Screen". In the Capture Screen, I am using the SCRecorder record method to record my video, and when I am done the recorder is paused using the SCRecorder paused method. When a "Next" button is pressed on this Capture Screen, it passes the recorder.session object (after the video is paused using paused w/ completion handler) to the Preview Capture Screen. This recorder.session object is then used to populate the video in the Preview Capture Screen. All works great, but one issue.
When the user presses "Next" button extremely quickly (less than a second) after the video is done recording, it fails to pass any content with the recorder.session object. In addition, the SCVideoPlayerView will be entirely Gray with no video or audio output.
Under the gray screen scenario, I've printed it out in the console ("po recordSession.assetRepresentingSegments()") and retrieved:
"<AVMutableComposition: 0x12da19310 tracks = ( )>"
Why is nothing being passed, and why is this an AVMutableComposition instead of an AVURLAsset?When I wait more than a second after recording to press the next button, it will successfully pass a valid object, when I print out the same recordSession.assetRepresentingSegments():
<AVURLAsset: 0X12d87a870, URL = file:///private/var/mobile......SCVideo.0.mp4>
Has anyone else experienced a gray screen issue, or no contents in assetRepresentingSegments?
SCREENSHOTS:
//Invalid, causing gray screen![screenshot2](https://cloud.githubusercontent.com/assets/9359439/16784864/bd5cd67c-483f-11e6-9df6-1bdf13948184.png)
//Valid, no gray screen![screenshot3](https://cloud.githubusercontent.com/assets/9359439/16784865/bd5dd504-483f-11e6-97fb-0083a3c7c31b.png)
//recordSession.assetsRepresentingSegments either has or does not have proper contents for video![screenshot1](https://cloud.githubusercontent.com/assets/9359439/16784866/bd607b1a-483f-11e6-8601-8ff97e6b27d9.png)