Reputation: 843
I'm trying to create a video player with controls for Android TV with Flutter
The basic video_player is working: https://gist.github.com/andraskende/195e746716e5e4e978356abb09e66a37
Would like to enhance the controls:
I tried to add RawKeyboardListener to listen on a keypress on remote but then the controls are not selectable as the RawKeyboardListener takes over..
I guess when the controls are hidden I need RawKeyboardListener to bring up the controls and disable the RawKeyboardListener so the control buttons can be selected.
Any help is greatly appreciated.
Thanks, Andras
Upvotes: 0
Views: 1817
Reputation: 288
I faced similar kind of issue where I fixed it with below code:
void _onKey(RawKeyEvent e) {
controls();
if (e.runtimeType.toString() == 'RawKeyDownEvent') {
switch (e.logicalKey.debugName) {
case 'Media Play Pause':
case 'Select':
setState(() {
if (_videoViewController.value.isPlaying) {
_videoViewController.pause();
} else {
_videoViewController.play();
}
});
break;
}
}`
Now if you wanted to have a fast forward or back just use the RawKeyboardListener with specific case to handle it.
You can also use your D-PAD keys to perform such action.
Upvotes: 2