nosnia-audio-recorder 0.8.5 → 0.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -85,19 +85,20 @@ class NosniaAudioPlayerModule(private val reactContext: ReactApplicationContext)
85
85
 
86
86
  mediaPlayer?.release()
87
87
 
88
+ val module = this
88
89
  mediaPlayer = MediaPlayer().apply {
89
90
  setDataSource(filePath)
90
91
  setVolume(volume, volume)
91
92
  isLooping = loop
92
93
 
93
94
  setOnCompletionListener {
94
- isPlaying = false
95
+ module.isPlaying = false
95
96
  stopProgressUpdates()
96
97
  sendEvent("onPlaybackComplete", Arguments.createMap())
97
98
  }
98
99
 
99
100
  setOnErrorListener { _, _, _ ->
100
- isPlaying = false
101
+ module.isPlaying = false
101
102
  stopProgressUpdates()
102
103
  true
103
104
  }
@@ -106,14 +107,14 @@ class NosniaAudioPlayerModule(private val reactContext: ReactApplicationContext)
106
107
  start()
107
108
  }
108
109
 
109
- isPlaying = true
110
- currentFilePath = filePath
110
+ this.isPlaying = true
111
+ this.currentFilePath = filePath
111
112
  startProgressUpdates()
112
113
  promise.resolve(null)
113
114
  } catch (e: Exception) {
114
115
  mediaPlayer?.release()
115
116
  mediaPlayer = null
116
- isPlaying = false
117
+ this.isPlaying = false
117
118
  promise.reject("START_PLAYING_ERROR", e.message, e)
118
119
  }
119
120
  }
@@ -130,8 +131,8 @@ class NosniaAudioPlayerModule(private val reactContext: ReactApplicationContext)
130
131
  release()
131
132
  }
132
133
  mediaPlayer = null
133
- isPlaying = false
134
- currentFilePath = null
134
+ this.isPlaying = false
135
+ this.currentFilePath = null
135
136
 
136
137
  promise.resolve(null)
137
138
  } catch (e: Exception) {
@@ -142,13 +143,13 @@ class NosniaAudioPlayerModule(private val reactContext: ReactApplicationContext)
142
143
  @ReactMethod
143
144
  fun pausePlaying(promise: Promise) {
144
145
  try {
145
- if (!isPlaying || mediaPlayer == null) {
146
+ if (!this.isPlaying || mediaPlayer == null) {
146
147
  promise.reject("NOT_PLAYING", "No playback in progress")
147
148
  return
148
149
  }
149
150
 
150
151
  mediaPlayer?.pause()
151
- isPlaying = false
152
+ this.isPlaying = false
152
153
  promise.resolve(null)
153
154
  } catch (e: Exception) {
154
155
  promise.reject("PAUSE_ERROR", e.message, e)
@@ -158,13 +159,13 @@ class NosniaAudioPlayerModule(private val reactContext: ReactApplicationContext)
158
159
  @ReactMethod
159
160
  fun resumePlaying(promise: Promise) {
160
161
  try {
161
- if (isPlaying || mediaPlayer == null) {
162
+ if (this.isPlaying || mediaPlayer == null) {
162
163
  promise.reject("NOT_PAUSED", "Playback is not paused")
163
164
  return
164
165
  }
165
166
 
166
167
  mediaPlayer?.start()
167
- isPlaying = true
168
+ this.isPlaying = true
168
169
  promise.resolve(null)
169
170
  } catch (e: Exception) {
170
171
  promise.reject("RESUME_ERROR", e.message, e)
@@ -207,7 +208,7 @@ class NosniaAudioPlayerModule(private val reactContext: ReactApplicationContext)
207
208
  fun getPlayerStatus(promise: Promise) {
208
209
  try {
209
210
  val status = WritableNativeMap().apply {
210
- putBoolean("isPlaying", isPlaying)
211
+ putBoolean("isPlaying", this@NosniaAudioPlayerModule.isPlaying)
211
212
 
212
213
  if (mediaPlayer != null) {
213
214
  putDouble("duration", mediaPlayer!!.duration.toDouble())
@@ -217,8 +218,8 @@ class NosniaAudioPlayerModule(private val reactContext: ReactApplicationContext)
217
218
  putDouble("currentTime", 0.0)
218
219
  }
219
220
 
220
- if (currentFilePath != null) {
221
- putString("currentFilePath", currentFilePath)
221
+ if (this@NosniaAudioPlayerModule.currentFilePath != null) {
222
+ putString("currentFilePath", this@NosniaAudioPlayerModule.currentFilePath)
222
223
  }
223
224
  }
224
225
  promise.resolve(status)
@@ -47,10 +47,9 @@ class NosniaAudioRecorderModule(private val reactContext: ReactApplicationContex
47
47
  progressHandler.postDelayed(this, 100) // Update every 100ms
48
48
  }
49
49
  }
50
- }
51
50
 
52
51
  private fun sendEvent(eventName: String, params: WritableMap?) {
53
- reactApplicationContext
52
+ reactContext
54
53
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
55
54
  .emit(eventName, params)
56
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nosnia-audio-recorder",
3
- "version": "0.8.5",
3
+ "version": "0.8.7",
4
4
  "description": "This is a modern audio recorder which actually works cross platform",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",