Skip to content
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

Picture in picture doesn't support android 14 #74

Open
this-sunil opened this issue Nov 30, 2024 · 2 comments
Open

Picture in picture doesn't support android 14 #74

this-sunil opened this issue Nov 30, 2024 · 2 comments

Comments

@this-sunil
Copy link

android api level 34 but not work picture in picture theoplayer,audio and video tracks emty and subtitle not work

@this-sunil
Copy link
Author

why native code added in flutter project side directly call programatically , because controls can't hide when pip mode and when initialize time theoplayer issue and pip mode aspect ration inside code issue class _PlayerPlatformActivityServiceListener implements PlatformActivityServiceListener {

THEOplayer player;

_PlayerPlatformActivityServiceListener({required this.player});

@OverRide
void onExitPictureInPicture() {
debugLog("THEOplayer_$playerID: PlayerPlatformActivityServiceListener onExitPictureInPicture");

if (!player.allowAutomaticPictureInPicture) {
  debugLog("THEOplayer_$playerID: PlayerPlatformActivityServiceListener onExitPictureInPicture not for me");
  return;
}

player._setPresentationMode(player._presentationModeBeforePip);

}

@OverRide
void onUserLeaveHint() {
debugLog("THEOplayer_$playerID:: PlayerPlatformActivityServiceListener onUserLeaveHint");

if (!player.allowAutomaticPictureInPicture) {
  debugLog("THEOplayer_$playerID: PlayerPlatformActivityServiceListener onUserLeaveHint not for me");
  return;
}

player._setPresentationMode(PresentationMode.PIP, userTriggered: false);

if (Platform.isIOS) {
  //do nothing, AVplayer will do the transition
} else {
  var pipModeFullscreenWidget = _FakePiPFullscreenWindow(player: player);

  MaterialPageRoute pipRoute = MaterialPageRoute(
      builder: (context) {
        return pipModeFullscreenWidget;
      },
      settings: null);

  Navigator.of(player._currentContext, rootNavigator: true).push(pipRoute);
}

}

@OverRide
void onPlayActionReceived() {
debugLog("THEOplayer_$playerID:: PlayerPlatformActivityServiceListener onPlayActionReceived");

if (!player.allowAutomaticPictureInPicture) {
  debugLog("THEOplayer_$playerID: PlayerPlatformActivityServiceListener onPlayActionReceived not for me");
  return;
}

player.play();

}

@OverRide
void onPauseActionReceived() {
debugLog("THEOplayer_$playerID:: PlayerPlatformActivityServiceListener onPauseActionReceived");

if (!player.allowAutomaticPictureInPicture) {
  debugLog("THEOplayer_$playerID: PlayerPlatformActivityServiceListener onPauseActionReceived not for me");
  return;
}

player.pause();

}

@OverRide
int get playerID => player.id;

}
/// We use this widget to present the player in "fullscreen" to make it fully visible in PiP without any UI elements
class _FakePiPFullscreenWindow extends StatelessWidget {
const _FakePiPFullscreenWindow({
super.key,
required this.player,
});

final THEOplayer player;

@OverRide
Widget build(BuildContext context) {
return Container(
color: Colors.black,
child: Align(
alignment: Alignment.center,
child: AspectRatio(
aspectRatio: player.getVideoWidth() / player.getVideoHeight(),
child: PresentationModeAwareWidget(player: player, presentationModeToCheck: const [PresentationMode.PIP]))));
}
}

@this-sunil
Copy link
Author

this-sunil commented Dec 1, 2024

theoplayer so much consume
space in flutter optimize proguard rules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant