在leanback库中的Playback Overlay片段中连续按下按钮

时间:2016-08-17 12:27:33

标签: android android-tv leanback

我在我的Android TV应用程序中使用播放覆盖片段进行视频控制。问题是我想知道按钮是否持续按下。但是在回调中我只知道它何时被按下。

this.mPlayBackControlsRowPresenter.setOnActionClickedListener(new OnActionClickedListener() {
        public void onActionClicked(Action action) {
            PlaybackControlFragment playbackControlFragment = (PlaybackControlFragment)getFragmentManager().findFragmentById(R.id.playback_controls_fragment);
            if (action.getId() == playbackControlFragment.getPlayPause().getId()) {
                /* PlayPause action */
            } else if (action.getId() == playbackControlFragment.getPlayNext().getId()) {
                /* SkipNext action */
               // mMediaController.getTransportControls().skipToNext();
            } else if (action.getId() == playbackControlFragment.getPlayPrevious().getId()) {
                /* SkipPrevious action */
               // mMediaController.getTransportControls().skipToPrevious();
            } else if (action.getId() == playbackControlFragment.getForward().getId()) {
                /* FastForward action  */
              //  mMediaController.getTransportControls().fastForward();
            } else if (action.getId() == playbackControlFragment.getRewind().getId()) {
                /* Rewind action */
              //  mMediaController.getTransportControls().rewind();
            }


        }
    });

1 个答案:

答案 0 :(得分:0)

如果用户连续按下按钮,则会触发多个事件,您可以围绕连续事件编写逻辑并根据状态修改行为