mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2026-10-13 11:11:51 +00:00
Fix black video delay when entering fullscreen
This commit is contained in:
@@ -1295,9 +1295,15 @@ public final class VideoDetailFragment
|
||||
player.UIs().get(MainPlayerUi.class).ifPresent(playerUi -> {
|
||||
// sometimes binding would be null here, even though getView() != null above u.u
|
||||
if (binding != null) {
|
||||
// prevent from re-adding a view multiple times
|
||||
playerUi.removeViewFromParent();
|
||||
binding.playerPlaceholder.addView(playerUi.getBinding().getRoot());
|
||||
// Only reparent the view if it's not already in the playerPlaceholder.
|
||||
// Removing and re-adding a SurfaceView destroys its native surface,
|
||||
// causing a black screen until the video decoder hits the next
|
||||
// keyframe (2-5 seconds on typical DASH/HLS streams).
|
||||
if (playerUi.getBinding().getRoot().getParent()
|
||||
!= binding.playerPlaceholder) {
|
||||
playerUi.removeViewFromParent();
|
||||
binding.playerPlaceholder.addView(playerUi.getBinding().getRoot());
|
||||
}
|
||||
playerUi.setupVideoSurfaceIfNeeded();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user