Skip to content

Commit

Permalink
Cleanup unnecessary code and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
123mpozzi committed Oct 18, 2024
1 parent 7fde45f commit 5c04e05
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ abstract class BitmovinBaseModule(
}
}

protected inline fun <T, R : T> TPromise<T>.runOnUiThread(
crossinline block: () -> Unit,
) {
val uiManager = runAndRejectOnException { uiManager } ?: return
uiManager.addUIBlock {
block()
}
}

protected val RejectPromiseOnExceptionBlock.playerModule: PlayerModule get() = context.playerModule
?: throw IllegalArgumentException("PlayerModule not found")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import com.bitmovin.player.api.media.session.MediaSessionService

class MediaSessionPlaybackService : MediaSessionService() {
inner class ServiceBinder : Binder() {
// When the service starts, it creates a player
// When playback activity is created, it gets a binder and
// goes to the service and gets the player from it -- the same player instance.
var player: Player?
get() = this@MediaSessionPlaybackService.player
set(value) {
Expand All @@ -35,18 +32,10 @@ class MediaSessionPlaybackService : MediaSessionService() {

override fun onGetSession(): MediaSession? = mediaSession

// Player has 2 pointers: one from application, one from service
// but is the same instance.
// So when it loses the application one, it still does not get
// garbage-collected because it still has a strong reference.
override fun onCreate() {
super.onCreate()
// [!!] I need to get the same react-native instance of the player here
val player = this.player ?: Player(this)

// cannot create mediaSession without a player
// TODO: call playerModule.createPlayer to actually create a player
// so then we'll go to `mediaSessionModule.. onServiceConnected`
mediaSession = MediaSession(
this,
mainLooper,
Expand All @@ -71,7 +60,7 @@ class MediaSessionPlaybackService : MediaSessionService() {
private fun createMediaSession(player: Player) {
binder.disconnectSession()

val newMediaSession = MediaSession(// the real media session
val newMediaSession = MediaSession(
this,
mainLooper,
player,
Expand Down

0 comments on commit 5c04e05

Please sign in to comment.