我有一个适用于 Amazon Fire 电视和电视棒的媒体应用程序。我已成功捕获按钮并相应地自定义了事件。当其他一些媒体应用程序(例如潘多拉)在后台运行时,就会出现问题。当我在我的应用程序中快进、快退等时,甚至潘多拉都会在此过程中发生变化。亚马逊出于同样的原因拒绝了该应用程序。如何仅在当前应用程序中设置遥控器的焦点。以下是我的远程代码
@Override
public boolean onKeyDown(int keyCode, KeyEvent event){
boolean handled = false;
switch (keyCode){
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_DPAD_LEFT:
mPlayerView.seek((int)mPlayerView.getPosition()-3000);
handled = true;
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
Log.e("right","pressed");
mPlayerView.seek((int)mPlayerView.getPosition()+3000);
handled = true;
break;
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
mPlayerView.seek((int)mPlayerView.getPosition()+60000);
handled=true;
break;
case KeyEvent.KEYCODE_MEDIA_REWIND:
mPlayerView.seek((int)mPlayerView.getPosition()-60000);
handled=true;
break;
case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
mPlayerView.play();
handled=true;
break;
case KeyEvent.KEYCODE_MENU:
subtitle=!subtitle;
if(subsexists){
if(subtitle) {
mPlayerView.setCurrentCaptions(1);
Toast.makeText(this,"Subtitles ON",Toast.LENGTH_LONG).show();
}
else {
mPlayerView.setCurrentCaptions(0);
Toast.makeText(this,"Subtitles OFF",Toast.LENGTH_LONG).show();
}
}
handled=true;
break;
}
return handled || super.onKeyDown(keyCode, event);
}