6.3 C
New York
Friday, April 11, 2025

android – Exiting Fullscreen of video results in standing bar hidden concern i’m utilizing chewie controller and video controller


I’m utilizing chewie and video controller in my app , on the video Fullscreen exit the standing bar hides when i exit from full display screen mode for full app the standing bar concern occurs then.

My code snippet:

import 'package deal:flutter/materials.dart';
import 'package deal:flutter_riverpod/flutter_riverpod.dart';
import 'package deal:frequency_app/core/constants/app_colors.dart';
import 'package deal:video_player/video_player.dart';
import 'package deal:chewie/chewie.dart';

/// **Video Participant Controller Supplier**
closing videoPlayerControllerProvider = FutureProvider.autoDispose((ref) async {
  closing controller = VideoPlayerController.networkUrl(
    Uri.parse('https://flutter.github.io/assets-for-api-docs/property/movies/bee.mp4'),
    videoPlayerOptions: VideoPlayerOptions(
      allowBackgroundPlayback: false,
      mixWithOthers: true,
    ),
  );

  await controller.initialize();
  // await controller.play();
  controller.setLooping(true);

  /// **Listener to trace progress and buffering**
  controller.addListener(() {
    closing videoValue = controller.worth;
    closing currentPosition = videoValue.place.inMilliseconds;
    closing length = videoValue.length.inMilliseconds;

    if (videoValue.isBuffering) {
      print("Video is buffering...");
      ref.learn(isBufferingProvider.notifier).state = true;
    } else if (videoValue.isPlaying) {
      ref.learn(isBufferingProvider.notifier).state = false;
    }else {
      ref.learn(isBufferingProvider.notifier).state = false;
      ref.learn(playPauseProvider.notifier).resumeAfterBuffering(controller);  // Resume video after buffering
    }
    ref.learn(videoProgressProvider.notifier).state =
    videoValue.length.inMilliseconds > 0
        ? videoValue.place.inMilliseconds / videoValue.length.inMilliseconds
        : 0.0;
   
    if (videoValue.isPlaying && currentPosition > 500 && currentPosition < length) {
      ref.learn(isBufferingProvider.notifier).state = false;
    }
    if (!controller.worth.isBuffering &&
        !controller.worth.isPlaying) {
      controller.play();
    }
   
    closing progress = length > 0 ? currentPosition / length : 0.0;
    ref.learn(videoProgressProvider.notifier).state = progress;
  });

  ref.onDispose(() {
    controller.pause();
    controller.dispose();
  });

  return controller;
});

/// **Chewie Controller Supplier**
closing chewieControllerProvider = FutureProvider.autoDispose((ref) async {
  closing videoController = await ref.watch(videoPlayerControllerProvider.future);
  if (!videoController.worth.isInitialized) {
    await videoController.initialize();
  }

  closing chewieController = ChewieController(
    videoPlayerController: videoController,
    autoPlay: false,
    looping: true,
    showControls: true,
    showControlsOnInitialize: true,
    aspectRatio: videoController.worth.aspectRatio > 0 ? videoController.worth.aspectRatio : 16 / 9,
    allowFullScreen: true,
    allowMuting: true,
    allowPlaybackSpeedChanging: true,
    customControls: CustomChewieControls(),
    progressIndicatorDelay: Length.zero,
  );

  ref.onDispose(() {
    chewieController.dispose();
  });

  return chewieController;
});

class CustomChewieControls extends ConsumerWidget {
  const CustomChewieControls({tremendous.key});

  @override
  Widget construct(BuildContext context, WidgetRef ref) {
    closing videoController = ChewieController.of(context).videoPlayerController;
    closing isPlaying = ref.watch(playPauseProvider);
    closing isMuted = ref.watch(muteProvider);

    return Stack(
      youngsters: [
        // ✅ Background Visibility
        Positioned.fill(
          child: Container(color: Colors.black.withOpacity(0.3)),
        ),

        // ✅ Controls (Fullscreen, Mute, Seek, Play/Pause)
        Align(
          alignment: Alignment.bottomCenter,
          child: Padding(
            padding: const EdgeInsets.only(bottom: 10.0),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                IconButton(
                  icon: Icon(Icons.fullscreen, color: Colors.white),
                  onPressed: () => ChewieController.of(context).enterFullScreen(),
                ),
              ],
            ),
          ),
        ),
      ],
    );
  }
}

I’ve tried Restoring System UI Model on Fullscreen Exit.
i additionally tried deviceOrientationsAfterFullScreen

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles