rFlex / SCRecorder

iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing
Apache License 2.0
3.06k stars 583 forks source link

How to Stop Recording and Reset It? #400

Open kuldeep13990 opened 7 years ago

kuldeep13990 commented 7 years ago

I have SCRecorder in TabBar and user can swipe TabBar to move between ViewControllers,

if i start Recording and move to another viewController and than come back to Recording screen i want to reset SCRecorder screen like timer and etc.

For stop recording i put this code in ViewWillAppear

[_recorder pause:^{
            [self saveAndShowSession:_recorder.session];
        }];

SCRecordSession *recordSession = _recorder.session;
    self.lblRecordingTime.text = @"00:00";
    if (recordSession != nil) {
        _recorder.session = nil;

        // If the recordSession was saved, we don't want to completely destroy it
        if ([[SCRecordSessionManager sharedInstance] isSaved:recordSession]) {
            [recordSession endSegmentWithInfo:nil completionHandler:nil];
        } else {
            [recordSession cancelSession:nil];
        }
    }

    [self prepareSession];

It will Crash while i came to recording screen for multiple times. i check it out where it crash. Below is the code where it crash.

NSDictionary *metadata = recordSession.dictionaryRepresentation;

        if (insertIndex == -1) {
            [metadatas addObject:metadata];
        } else {
            [metadatas replaceObjectAtIndex:insertIndex withObject:metadata];
        }

Now can you help how can i stop and reset Recording Screen?

Thanks