abdelaziz-mahdy / flutter_meedu_videoplayer

Cross-Platform Video Player for flutter
https://abdelaziz-mahdy.github.io/flutter_meedu_videoplayer/
MIT License
132 stars 69 forks source link

Disable gestures (?) #115

Closed sommye-ctr closed 1 year ago

sommye-ctr commented 1 year ago

Does the player support turning off the gestures? I'm passing custom widget and also setting the controls style to custom but still the gestures are on.

Actually I'm trying to implement my own focusable widgets and therefore require focus childs but when passing the custom widget it the key presses are not passed to my custom widget. Is there a way to implement this?

abdelaziz-mahdy commented 1 year ago

where are the custom widgets located on screen?

and yes you can disable anything you dont want

example:

 enabledControls: const EnabledControls(doubleTapToSeek: false)
sommye-ctr commented 1 year ago

Im passing the controls in the customControls parameter.

The widget passed is a scaffold which covers the entire screen showing various components (seekbar title etc). There is also RawkeyboardListener but the events are not passed there (maybe the controls of the player doesnt allow traversal of focus?). Also I have set excludeFocus to false.

abdelaziz-mahdy commented 1 year ago

Im passing the controls in the customControls parameter.

The widget passed is a scaffold which covers the entire screen showing various components (seekbar title etc). There is also RawkeyboardListener but the events are not passed there (maybe the controls of the player doesnt allow traversal of focus?). Also I have set excludeFocus to false.

can you share an example? to be able to help you better?

since you did all the right things..

sommye-ctr commented 1 year ago

The top hierarchy is this and then there are just rows and columns for the widgets

` @override Widget build(BuildContext context) { return RawKeyboardListener(

  focusNode: focusNode,
  onKey: _onKey,
  child: Observer(
    builder: (context) {
      if (playerStore.showControls) {
        return Stack(
          children: [
            Container(
              height: double.infinity,
              width: double.infinity,
              color: Colors.black54,
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Stack(
                children: [
                  Align(
                    alignment: Alignment.topCenter,
                    child: _buildHeading(),
                  ),
                  _buildProgressControlsRow(),
                  if (playerStore.buffering)
                    Center(
                      child: CircularProgressIndicator(),
                    ),
                ],
              ),
            ),
          ],
        );
      }
      return Container();
    },
  ),
);

}`

abdelaziz-mahdy commented 1 year ago

The top hierarchy is this and then there are just rows and columns for the widgets

` @OverRide Widget build(BuildContext context) { return RawKeyboardListener(

  focusNode: focusNode,
  onKey: _onKey,
  child: Observer(
    builder: (context) {
      if (playerStore.showControls) {
        return Stack(
          children: [
            Container(
              height: double.infinity,
              width: double.infinity,
              color: Colors.black54,
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Stack(
                children: [
                  Align(
                    alignment: Alignment.topCenter,
                    child: _buildHeading(),
                  ),
                  _buildProgressControlsRow(),
                  if (playerStore.buffering)
                    Center(
                      child: CircularProgressIndicator(),
                    ),
                ],
              ),
            ),
          ],
        );
      }
      return Container();
    },
  ),
);

}`

can you provide an example i can run? since i need to test it to know what the problem

sommye-ctr commented 1 year ago

I'll provide one in few hours

sommye-ctr commented 1 year ago

Hey, I think I found what is causing this. By setting excludeFocus to false, the ExcludeFocus widget here sets its excluding property to false.

But still the customWidget is passed as a descendant of ControlsContainer, here. This ControlsContainer hinders in events in rawKeyboardListener (I'm not sure how).

Maybe we could change this behavior of always passing it to the ControlsContainer to something like passing it only when ControlsStyle is not custom.

abdelaziz-mahdy commented 1 year ago

Do you think you can provide a pr with your idea, which does not break existing code? If you can I would love it, since I still don't get the problem

sommye-ctr commented 1 year ago

Also if i set enabledControls to false and then pass the widgets in the following way:

` return Stack(

  children: [
    MeeduVideoPlayer(
      controller: controller,
      customCaptionView: (context, controller, responsive, text) {
        return Container(
          color: subBackground ?? false ? Colors.black : Colors.transparent,
          padding: EdgeInsets.all(6),
          child: Text(
            text,
            style: TextStyle(
              color: Colors.white,
              fontSize: subFontSize?.toDouble() ?? 14.0,
            ),
          ),
        );
      },
    ),
    Center(
        child: Text(
      "eheyryryyry",
      style: TextStyle(fontSize: 50),
    )),
    VideoPlayerControls(
      controller: controller,
      streamUrl: streamUrl,
      stream: widget.extensionStream,
      baseModel: widget.baseModel,
      episode: widget.episode,
      season: widget.season,
      movie: widget.movie,
      show: widget.show,
      progress: widget.progress,
      id: widget.id,
      fitIndex: fitIndex,
      autoSubtitle: autoSubtitle,
      detailsStore: widget.detailsStore,
      initialDark: initalDark,
      showHistory: widget.showHistory,
    ),
  ],
);

`

The Text and my custom Controls widget appear on screen for a split second and then they are hidden. I'm not able to understand why is this happening (maybe the player is hiding them in some way?).

sommye-ctr commented 1 year ago

Can you identify as to why the above thing is happening?

abdelaziz-mahdy commented 1 year ago

Also if i set enabledControls to false and then pass the widgets in the following way:

` return Stack(

  children: [
    MeeduVideoPlayer(
      controller: controller,
      customCaptionView: (context, controller, responsive, text) {
        return Container(
          color: subBackground ?? false ? Colors.black : Colors.transparent,
          padding: EdgeInsets.all(6),
          child: Text(
            text,
            style: TextStyle(
              color: Colors.white,
              fontSize: subFontSize?.toDouble() ?? 14.0,
            ),
          ),
        );
      },
    ),
    Center(
        child: Text(
      "eheyryryyry",
      style: TextStyle(fontSize: 50),
    )),
    VideoPlayerControls(
      controller: controller,
      streamUrl: streamUrl,
      stream: widget.extensionStream,
      baseModel: widget.baseModel,
      episode: widget.episode,
      season: widget.season,
      movie: widget.movie,
      show: widget.show,
      progress: widget.progress,
      id: widget.id,
      fitIndex: fitIndex,
      autoSubtitle: autoSubtitle,
      detailsStore: widget.detailsStore,
      initialDark: initalDark,
      showHistory: widget.showHistory,
    ),
  ],
);

`

The Text and my custom Controls widget appear on screen for a split second and then they are hidden. I'm not able to understand why is this happening (maybe the player is hiding them in some way?).

As I requested I really need an example to work with, if you have a GitHub repo and can give me access that will help fix this

But in anyway, most probably they get hidden waiting for the calls to make them reappear

Try to set 'controls' to true, and see if they are showing

abdelaziz-mahdy commented 1 year ago

Also I recommend using the custom controls logic already provided by the package since it helps greatly.

Check custom controls example

sommye-ctr commented 1 year ago

Yeah, all the things work as expected except one thing, that is RawkeyboardListener events in the customControls widget.

So for testing, you can basically wrap the custom controls example with a rawkeyboardListener and check if its onKey method is ever called. For me, the onKey method is never called and therefore i'm unable to perform some actions, I want.

abdelaziz-mahdy commented 1 year ago
image

works as expected, keep in mind now the video_player keyboard shortcuts doesnt work since they are not getting the focus

abdelaziz-mahdy commented 1 year ago
image

works as expected, keep in mind now the video_player keyboard shortcuts doesnt work since they are not getting the focus

image
sommye-ctr commented 1 year ago

I have no idea why is this not working when Im running the exact same code

abdelaziz-mahdy commented 1 year ago

This is why I asked for a full example, since maybe another part of the code is disabling your code

sommye-ctr commented 1 year ago

I think I figured out what was going wrong. Is it possible to turn off the feature where the player is automatically hiding (and showing on touch) the controls? I need to manage it on my own.

abdelaziz-mahdy commented 1 year ago

I think I figured out what was going wrong. Is it possible to turn off the feature where the player is automatically hiding (and showing on touch) the controls? I need to manage it on my own.

No sadly

sommye-ctr commented 1 year ago

Can it be implemented? Maybe you could direct me and Ill try looking into it

abdelaziz-mahdy commented 1 year ago

Can it be implemented? Maybe you could direct me and Ill try looking into it

Check controls setter, in the controller class, you can make a variable in the controls class

For auto hiding controls and use it there

sommye-ctr commented 1 year ago

Opened #118

abdelaziz-mahdy commented 1 year ago

released in 4.2.13