Skip to content
Merged
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
13 changes: 4 additions & 9 deletions android/src/main/java/com/audiowaveform/AudioWaveformModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,19 @@ 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
fun initRecorder(obj: ReadableMap?, promise: Promise) {
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)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1946,4 +1946,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 6f704d99bbe3053bd858eef7cb4caed0084ae50b

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
6 changes: 4 additions & 2 deletions ios/AudioPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down