android.widget.MediaController.dispatchKeyEvent()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中android.widget.MediaController.dispatchKeyEvent()方法的一些代码示例,展示了MediaController.dispatchKeyEvent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MediaController.dispatchKeyEvent()方法的具体详情如下:
包路径:android.widget.MediaController
类名称:MediaController
方法名:dispatchKeyEvent

MediaController.dispatchKeyEvent介绍

暂无

代码示例

代码示例来源:origin: fire3/sailorcast

@Override
  public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE
        || keyCode == KeyEvent.KEYCODE_MENU) {
      return false;
    }
    return mediaController.dispatchKeyEvent(event);
  }
});

代码示例来源:origin: amahi/android

@Override
  public boolean dispatchKeyEvent(KeyEvent event) {
    if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK) && (event.getAction() == KeyEvent.ACTION_DOWN)) {
      Activity activity = (Activity) getContext();
      activity.finish();

      return true;
    }

    return super.dispatchKeyEvent(event);
  }
}

代码示例来源:origin: fire3/sailorcast

@Override
  public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (playerControl.canSeekForward() && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
      if (event.getAction() == KeyEvent.ACTION_DOWN) {
        playerControl.seekTo(playerControl.getCurrentPosition() + 15000); // milliseconds
        show();
      }
      return true;
    } else if (playerControl.canSeekBackward() && keyCode == KeyEvent.KEYCODE_MEDIA_REWIND) {
      if (event.getAction() == KeyEvent.ACTION_DOWN) {
        playerControl.seekTo(playerControl.getCurrentPosition() - 5000); // milliseconds
        show();
      }
      return true;
    }
    return super.dispatchKeyEvent(event);
  }
}

相关文章