FastForwardAction does not respond to its input KeyEvent (KEYCODE_MEDIA_FAST_FORWARD)
SalehDehqanpour opened this issue · 1 comments
SalehDehqanpour commented
Consider this class and its source code. Although it implements this.addKeyCode(90);
in this line; but it does not respond to the event!
To Reproduce it:
- open the player and play video
- run this in shell :
input keyevent 90
Expected : forward action should be made
Current Result: No Response to event!
P.S. The play/pause event works perfectly but fast forward and rewind does not.
salehdeh76 commented
To fix this, Just Override this method. For example:
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) { // to handle fast forward and other keys, we overrided this!
switch(keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_DOWN:
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_BACK:
case KeyEvent.KEYCODE_ESCAPE:
return false;
default:
ObjectAdapter primaryActionsAdapter = getControlsRow().getPrimaryActionsAdapter();
Action action = getControlsRow().getActionForKeyCode(primaryActionsAdapter, keyCode);
if (action == null) {
action = getControlsRow().getActionForKeyCode(getControlsRow().getSecondaryActionsAdapter(), keyCode);
}
if (action != null) {
if (event.getAction() == 0) {
onActionClicked(action);
}
return true;
} else {
return false;
}
}
}