Skip to content

Commit

Permalink
Revert "fix: dehy#72"
Browse files Browse the repository at this point in the history
This reverts commit 6bad221.
  • Loading branch information
arakneaweb committed Nov 11, 2024
1 parent 6bad221 commit 9476565
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions android/src/main/java/com/radioplayer/RadioPlayerModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,13 @@ class RadioPlayerModule(reactContext: ReactApplicationContext) : ReactContextBas
@ReactMethod
fun play() {
UiThreadUtil.runOnUiThread {
android.util.Log.d(TAG, "1 play() called")
val player = controller
android.util.Log.d(TAG, "2 play() called $player")
if (player != null) {
if (player.isPlaying) {
android.util.Log.d(TAG, "3 play() called stop")
player.stop()
}
android.util.Log.d(TAG, "4 play() called")
player.prepare()
android.util.Log.d(TAG, "5 play() called")
player.play()
android.util.Log.d(TAG, "6 play() called")
}
}
}
Expand All @@ -167,14 +161,13 @@ class RadioPlayerModule(reactContext: ReactApplicationContext) : ReactContextBas
val player = controller
if (player != null) {
player.stop()
//player.release()
player.release()
}
}
}

private fun computeAndSendStateEvent() {
val previousState = this.state
android.util.Log.d(TAG, "computeAndSendStateEvent() called : playbackState $playbackState")

when (this.playbackState) {
Player.STATE_IDLE, Player.STATE_ENDED -> {
Expand All @@ -200,7 +193,6 @@ class RadioPlayerModule(reactContext: ReactApplicationContext) : ReactContextBas
}

override fun onPlaybackStateChanged(state: Int) {
android.util.Log.d(TAG, "onPlaybackStateChanged() called with: state = $state")
this.playbackState = state
computeAndSendStateEvent()
}
Expand All @@ -210,10 +202,7 @@ class RadioPlayerModule(reactContext: ReactApplicationContext) : ReactContextBas
eventName: String,
params: NativeMap
) {
android.util.Log.d(
TAG,
"sendEvent() called with: reactContext = $reactContext, eventName = $eventName, params = $params"
)

reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
.emit(eventName, params)
Expand Down

0 comments on commit 9476565

Please sign in to comment.