fix(android): force codec re-init on TV surface changes to recover video after screensaver

close #1481
This commit is contained in:
edde746
2026-07-04 19:25:56 +02:00
parent 50261398bf
commit dd09e421bf
3 changed files with 69 additions and 0 deletions
@@ -143,6 +143,21 @@ extension _VideoPlayerLifecycleMethods on VideoPlayerScreenState {
_recordLifecycleState('resumed', action: 'render_restored');
}
// TV never hides the render layer on background (_handleAppHidden returns
// early without setting _hiddenForBackground), but the screensaver can
// still destroy the surface. Kick the video output so a missed surface
// callback can't leave the picture black: mpv re-attaches via
// refreshVideoOutput, ExoPlayer just reapplies sizing/z-order.
if (!_hiddenForBackground &&
Platform.isAndroid &&
PlatformDetector.isTV() &&
currentPlayer != null &&
_isPlayerInitialized) {
await currentPlayer.updateFrame();
if (!mounted || currentPlayer != player) return;
_recordLifecycleState('resumed', action: 'tv_video_output_kick');
}
// Restore media controls and wakelock when app is resumed.
if (_isPlayerInitialized && mounted) {
_resumeMediaControlsAfterTvBackground('app_resumed');