THEOplayer / flutter-theoplayer-sdk

THEOplayer Flutter SDK
https://theoplayer.com
MIT License
12 stars 0 forks source link

Picture in picture doesn't support android 14 #74

Open this-sunil opened 2 days ago

this-sunil commented 2 days ago

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

this-sunil commented 1 day ago

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 commented 1 day ago

theoplayer so much consume space in flutter optimize proguard rules