Skip to content

Commit

Permalink
add timer to finish config before recording: Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
federico-bohn committed Nov 18, 2016
1 parent 4ff69ff commit 3c4a461
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions RCTOpenTokPublisherView.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ @implementation RCTOpenTokPublisherView {
BOOL _isSessionCreated;
BOOL _isPaused;
BOOL _isPublished;
NSTimer *_recordTimer;
}

/**
Expand Down Expand Up @@ -56,9 +55,6 @@ - (void) createSession {
} else {
_isSessionCreated = YES;
}

[_recordTimer invalidate];
_recordTimer = nil;
}

/**
Expand Down Expand Up @@ -244,21 +240,14 @@ - (void)session:(OTSession*)session didFailWithError:(OTError*)error {

#pragma mark - OTSession delegate - archive callbacks
- (void)session:(OTSession *)session archiveStartedWithId:(NSString *)archiveId name:(NSString *)name {
if (_recordTimer == nil) {
NSMutableArray *params = [NSMutableArray array];
[params addObject:archiveId];
[params addObject:name];
_recordTimer = [NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(_progressRecordTimerFired:) userInfo:params repeats:NO];
}
}

- (void)_progressRecordTimerFired:(NSTimer *)progressTimer {
_onArchiveStarted(@{
@"archiveId": progressTimer.userInfo[0],
@"name": progressTimer.userInfo[1],
});

[self saveThumbnail];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0f * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
_onArchiveStarted(@{
@"archiveId": archiveId,
@"name": name,
});

[self saveThumbnail];
});
}

- (void)session:(OTSession *)session archiveStoppedWithId:(NSString *)archiveId {
Expand Down

0 comments on commit 3c4a461

Please sign in to comment.