diff --git a/android/src/main/java/com/audiowaveform/AudioWaveformModule.kt b/android/src/main/java/com/audiowaveform/AudioWaveformModule.kt index 25b9376..6e2f7db 100644 --- a/android/src/main/java/com/audiowaveform/AudioWaveformModule.kt +++ b/android/src/main/java/com/audiowaveform/AudioWaveformModule.kt @@ -59,12 +59,12 @@ class AudioWaveformModule(context: ReactApplicationContext): ReactContextBaseJav @ReactMethod fun checkHasAudioRecorderPermission(promise: Promise) { - audioRecorder.checkPermission(currentActivity, promise) + audioRecorder.checkPermission(reactApplicationContext.currentActivity, promise) } @ReactMethod fun getAudioRecorderPermission(promise: Promise) { - audioRecorder.getPermission(currentActivity, promise) + audioRecorder.getPermission(reactApplicationContext.currentActivity, promise) } @ReactMethod @@ -72,11 +72,6 @@ class AudioWaveformModule(context: ReactApplicationContext): ReactContextBaseJav checkPathAndInitialiseRecorder(encoder, outputFormat, sampleRate, bitRate, promise, obj) } - @ReactMethod - fun getDecibel(): Double? { - return audioRecorder.getDecibel(recorder) - } - @ReactMethod fun startRecording(obj: ReadableMap?, promise: Promise) { initRecorder(obj, promise) @@ -379,7 +374,7 @@ class AudioWaveformModule(context: ReactApplicationContext): ReactContextBaseJav Log.e(Constants.LOG_TAG, "Failed to initialise Recorder") } if (path == null) { - val outputDir = currentActivity?.cacheDir + val outputDir = reactApplicationContext.currentActivity?.cacheDir val outputFile: File? val dateTimeInstance = SimpleDateFormat(Constants.fileNameFormat, Locale.US) val currentDate = dateTimeInstance.format(Date()) @@ -413,7 +408,7 @@ class AudioWaveformModule(context: ReactApplicationContext): ReactContextBaseJav private val emitLiveRecordValue = object : Runnable { override fun run() { - val currentDecibel = getDecibel() + val currentDecibel = audioRecorder.getDecibel(recorder) val args: WritableMap = Arguments.createMap() if (currentDecibel == Double.NEGATIVE_INFINITY) { args.putDouble(Constants.currentDecibel, 0.0) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 576567a..3445956 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1946,4 +1946,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 6f704d99bbe3053bd858eef7cb4caed0084ae50b -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/example/package.json b/example/package.json index c7e05ba..4105131 100644 --- a/example/package.json +++ b/example/package.json @@ -15,7 +15,7 @@ "react-native": "0.77.0", "react-native-fast-image": "^8.6.3", "react-native-fs": "^2.20.0", - "react-native-gesture-handler": "^2.23.1", + "react-native-gesture-handler": "2.25.0", "react-native-safe-area-context": "^5.2.0", "rn-fetch-blob": "^0.12.0" }, diff --git a/ios/AudioPlayer.swift b/ios/AudioPlayer.swift index 059f127..e171eb6 100644 --- a/ios/AudioPlayer.swift +++ b/ios/AudioPlayer.swift @@ -39,6 +39,8 @@ class AudioPlayer: NSObject, AVAudioPlayerDelegate { } do { + try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: []) + try AVAudioSession.sharedInstance().setActive(true) player = try AVAudioPlayer(contentsOf: audioUrl!) player?.prepareToPlay() player?.volume = Float(volume ?? 100.0) @@ -134,8 +136,8 @@ class AudioPlayer: NSObject, AVAudioPlayerDelegate { } func seekTo(_ time: Double?, _ result: @escaping RCTPromiseResolveBlock) { - if(time != 0 && time != nil) { - player?.currentTime = Double(time! / 1000) + if let time = time { + player?.currentTime = Double(time / 1000) result(true) } else { result(false) diff --git a/package.json b/package.json index 0f5e918..a0204b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@simform_solutions/react-native-audio-waveform", - "version": "2.1.5", + "version": "2.1.6", "description": "A React Native component to show audio waveform with ease in react native application", "main": "lib/index", "types": "lib/index.d.ts",