Home > Net >  How to identify if the controls has gone or not in flutter chewie video player
How to identify if the controls has gone or not in flutter chewie video player

Time:03-17

I am working on a flutter app and using chewie videoplayer plugin.So when we started playing a video it shows controls at bottom and after few seconds it vanishes and when we move the mouse again it shows again. so is there any method to find when the controls are shown on screen and when its not shown. actually i am giving close button on the video player. but it doesnt vanishes with those video player controls. it still stay on screen so to hide that close button along with video controls i need to get which process hides the control. Please help me...i need to know when these controls appears and hides

CodePudding user response:

This process is inside the source code of chewie player. So if you need to customize and synchronise your own custom controls and options, either you have to explicitly fetch the source code and edit in that or you need to make your own controllers from scratch using video_player package as the core.

CodePudding user response:

You need to customize the source code of the chewie player. You can find MaterialControl class inside the source code of this package there is a function called _buildHitArea() just change notifier.hideStuff boolean according to your preference.

Widget _buildHitArea() {
final bool isFinished = _latestValue.position >= _latestValue.duration;
final bool showPlayButton = widget.showPlayButton && !_dragging && !notifier.hideStuff;
return GestureDetector(
  onTap: () {
    if (_latestValue.isPlaying) {
      if (_displayTapped) {
        setState(() {
          notifier.hideStuff = false;
        });
      } else {
        _cancelAndRestartTimer();
      }
    } else {
      _playPause();

      setState(() {
        notifier.hideStuff = false;
      });
    }
  },
  child: CenterPlayButton(
    backgroundColor: Colors.black54,
    iconColor: Colors.white,
    isFinished: isFinished,
    isPlaying: controller.value.isPlaying,
    show: showPlayButton,
    onPressed: _playPause,
  ),
);

}

  • Related