Skip to content

Commit

Permalink
fix: bind or unbind Android audio service when casting or not (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jmilham21 authored May 21, 2024
1 parent 9fbc472 commit 6a6b633
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,16 @@ public void onCast(CastEvent castEvent) {
event.putBoolean("active", castEvent.isActive());
event.putBoolean("available", castEvent.isAvailable());
getReactContext().getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "topCasting", event);
// stop/start the background audio service if it's running and we're casting
if (castEvent.isActive()) {
doUnbindService();
} else {
if (backgroundAudioEnabled) {
mMediaServiceController = new MediaServiceController.Builder((AppCompatActivity) mActivity, mPlayer)
.build();
doBindService();
}
}
}

// LifecycleEventListener
Expand Down

0 comments on commit 6a6b633

Please sign in to comment.