Skip to content

Commit

Permalink
Merge pull request #282 from kot331107/Android---add-a-build-flag-to-…
Browse files Browse the repository at this point in the history
…optionally-turn-off-reparenting-on-fullscreen-event

Feature/Android: add build flag to make re-parenting optional
  • Loading branch information
tvanlaerhoven authored Mar 15, 2024
2 parents 0b287e4 + a5a8242 commit acb9f22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ android {
def TimeUpdateRate = "com.theoplayer.TimeUpdateRate"
buildConfigField TimeUpdateRate, "TIMEUPDATE_RATE", safeExtGet('THEOplayer_timeUpdateRate', "${TimeUpdateRate}.UNLIMITED")

// Optionally re-parent player view on fullscreen event
buildConfigField "boolean", "REPARENT_ON_FULLSCREEN", "${safeExtGet('THEOplayer_reparent_on_fullscreen', 'true')}"

// Optionally log events to logcat
buildConfigField "boolean", "LOG_PLAYER_EVENTS", "${safeExtGet('THEOplayer_logPlayerEvents', 'false')}"
buildConfigField "boolean", "LOG_VIEW_EVENTS", "${safeExtGet('THEOplayer_logViewEvents', 'false')}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.lifecycle.Lifecycle
import com.facebook.react.ReactRootView
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.views.view.ReactViewGroup
import com.theoplayer.BuildConfig
import com.theoplayer.PlayerEventEmitter
import com.theoplayer.ReactTHEOplayerContext
import com.theoplayer.android.api.error.ErrorCode
Expand Down Expand Up @@ -208,6 +209,9 @@ class PresentationManager(
}.hide(WindowInsetsCompat.Type.systemBars())
updatePresentationMode(PresentationMode.FULLSCREEN)

if (!BuildConfig.REPARENT_ON_FULLSCREEN) {
return
}
playerGroupParentNode = (reactPlayerGroup?.parent as ReactViewGroup?)?.also { parent ->
playerGroupChildIndex = parent.indexOfChild(reactPlayerGroup)
// Re-parent the playerViewGroup to the root node
Expand All @@ -220,6 +224,9 @@ class PresentationManager(
)
updatePresentationMode(PresentationMode.INLINE)

if (!BuildConfig.REPARENT_ON_FULLSCREEN) {
return
}
root?.run {
// Re-parent the playerViewGroup from the root node to its original parent
removeView(reactPlayerGroup)
Expand Down

0 comments on commit acb9f22

Please sign in to comment.