diff --git a/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt b/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt index 5ab3c90e..665d5c1c 100644 --- a/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt +++ b/android/src/main/java/com/dooboolab.audiorecorderplayer/RNAudioRecorderPlayerModule.kt @@ -303,14 +303,13 @@ class RNAudioRecorderPlayerModule(private val reactContext: ReactApplicationCont } @ReactMethod - fun seekToPlayer(time: Int, promise: Promise) { + fun seekToPlayer(time: Double, promise: Promise) { if (mediaPlayer == null) { promise.reject("seekTo", "mediaPlayer is null on seek.") return } - val millis = time * 1000 - mediaPlayer!!.seekTo(millis) + mediaPlayer!!.seekTo(time.toInt()) promise.resolve("pause player") } diff --git a/index.ts b/index.ts index 7311e2c3..140a786f 100644 --- a/index.ts +++ b/index.ts @@ -359,12 +359,10 @@ class AudioRecorderPlayer { /** * Seek to. - * @param {number} time position seek to in second. + * @param {number} time position seek to in millisecond. * @returns {Promise} */ seekToPlayer = async (time: number): Promise => { - if (Platform.OS === 'ios') time = time / 1000; - return RNAudioRecorderPlayer.seekToPlayer(time); }; diff --git a/ios/RNAudioRecorderPlayer.swift b/ios/RNAudioRecorderPlayer.swift index d08d3539..a82e1538 100644 --- a/ios/RNAudioRecorderPlayer.swift +++ b/ios/RNAudioRecorderPlayer.swift @@ -388,7 +388,7 @@ class RNAudioRecorderPlayer: RCTEventEmitter, AVAudioRecorderDelegate { return reject("RNAudioPlayerRecorder", "Player is null", nil) } - audioPlayer.seek(to: CMTime(seconds: time, preferredTimescale: CMTimeScale(NSEC_PER_SEC))) + audioPlayer.seek(to: CMTime(seconds: time / 1000, preferredTimescale: CMTimeScale(NSEC_PER_SEC))) resolve("Resumed!") }