flutter-meedu-player icon indicating copy to clipboard operation
flutter-meedu-player copied to clipboard

[Enhancment] Change Buttons to be focusable buttons. Gives DPAD support for Android TV apps.

Open YaarPatandarAA opened this issue 3 years ago • 1 comments

Hello, I have a suggestion for changing the buttons to be buttons that can be focused on. This can be done simply by replacing the CupertinoButton with a MaterialButton, with a little padding and size tweaking.

WHY: This will allow the use of a DPAD, if one was to use their application on an Android TV.

I tested this by replacing the CupertinoButton with a MaterialButton and it worked for my app on an Android TV. However I wasn't able to figure out the sizing and padding.

p.s.

  • Additionally to support DPAD you will have to remove focus from the Slider.
  • This is because flutter Slider doesn't work well with a DPAD, yet. https://github.com/flutter/flutter/issues/54984
  • You can do this by adding the following to the Slider: focusNode: FocusNode(canRequestFocus: false).
  • There maybe other ways to prevent focus on the Slider.
  • This does not break touch, touch will still work normally as it already does.
  • This can be reverted back if and when Flutter adds DPAD support to the slider
  • Seeking on Android TV can be done by using the forward-10 and replay-10 until the Slider is fully DPAD operational.

YaarPatandarAA avatar Jan 13 '21 05:01 YaarPatandarAA

Adding onto the Android TV support suggestion.

  • Start off by having autoFocus: true on one of the buttons, I would suggest the play/pause button.
  • Check to see if buttons are hidden, if so make the reappear when a DPAD button is clicked. Use of the RawKeyboardListener class will be needed to listen for physical button clicks.
  • If buttons are hidden prevent them from being executed until they come back to visibility. This is because if they are already in focus the DPAD will still click them even if they are hidden and they will execute, that is why we need the above to show the controls

This could possibly be done on the Android Platform side, all of the above is Flutter side suggestion. I can try to attempt the above myself but because I am not familiar with meedu-player code, yet, it may take me much longer than you (@darwin-morocho)

YaarPatandarAA avatar Jan 13 '21 06:01 YaarPatandarAA