-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce onPictureInPictureModeChanged to FlutterPlayerView (PiP #2) #86
Conversation
…ation-change-handling # Conflicts: # android/src/main/kotlin/com/bitmovin/player/flutter/FlutterPlayerView.kt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 👍
isInPictureInPictureMode: Boolean, | ||
newConfig: Configuration, | ||
) { | ||
// TODO: Handle picture in picture mode changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this TODO
will be part of a future PR, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes 🙂
…ation-change-handling # Conflicts: # android/src/main/kotlin/com/bitmovin/player/flutter/FlutterPlayerView.kt
I found an issue with the component callbacks on Android 10 and had to change the implementation. Please review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some minor NIT/ a question.
@@ -111,6 +119,28 @@ class FlutterPlayerView( | |||
sink = null | |||
} | |||
|
|||
private fun PlayerView.setOnPictureInPictureModeChanged(callback: (Boolean, Configuration) -> Unit) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private fun PlayerView.setOnPictureInPictureModeChanged(callback: (Boolean, Configuration) -> Unit) { | |
private fun PlayerView.setOnPictureInPictureModeChangedCallback(callback: (Boolean, Configuration) -> Unit) { |
Where will this function be called from? I can't see any usage yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be called from the init block where we check out the playerView arguments. Right after the fullscreen handler initialization.
android/src/main/kotlin/com/bitmovin/player/flutter/FlutterPlayerView.kt
Outdated
Show resolved
Hide resolved
…yerView.kt Co-authored-by: Lukas Knoch-Girstmair <strangesource@users.noreply.github.com>
…yerView.kt Co-authored-by: Lukas Knoch-Girstmair <strangesource@users.noreply.github.com>
Description
There is currently no way to get notified from the OS that PiP mode has been activated.
Listening to PiP changes usually happens by overriding onPictureInPictureModeChanged in the Activity. This is not really doable in a SDK context since the library consumer actually controls the activity.
To work around this issue, this PR introduces aComponentCallbacks
instance registered to an instance of the Activity, this way we can get notified about configuration changes.Edit: unfortunately, component callbacks don't work for some Android versions (tested on Android 10 with FlutterFragmentActivity). My suspicion is that it's an issue in Flutter's activity - since one can also observe activity getting a red color overlay.
The configuration change listening is now done by overriding view's
onConfigurationChanged
. Since Flutter's PlatformView isn't actually an Android View we have to add a blank view to the PlayerView in order to be able to override the mentioned function.In combination with activity.isInPictureInPictureMode we can imitate Activity's onPictureInPictureModeChanged.
This PR is prework for PiP implementation.
Changes
onPictureInPictureModeChanged
callbackTests
Checklist (for PR submitters and reviewers)
CHANGELOG.md
entry for new/changed features, bug fixes or important code changes