Skip to content
This repository was archived by the owner on Aug 21, 2020. It is now read-only.

Add getCurrentTime to iOS #304

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ var AudioRecorder = {
stopRecording: function() {
return AudioRecorderManager.stopRecording();
},
getCurrentTime: function() {
if (Platform.OS === 'ios') {
return AudioRecorderManager.getCurrentTime();
}
},
checkAuthorizationStatus: AudioRecorderManager.checkAuthorizationStatus,
requestAuthorization: () => {
if (Platform.OS === 'ios')
Expand Down
11 changes: 11 additions & 0 deletions ios/AudioRecorderManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,17 @@ - (NSString *) applicationDocumentsDirectory
}];
}

RCT_EXPORT_METHOD(getCurrentTime:(RCTPromiseResolveBlock)resolve
rejecter:(__unused RCTPromiseRejectBlock)reject)
{
if (_audioRecorder && _audioRecorder.isRecording) {
resolve(@(_audioRecorder.currentTime));
} else {
resolve(@"NO");
}
}


- (NSString *)getPathForDirectory:(int)directory
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(directory, NSUserDomainMask, YES);
Expand Down