當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE屬性代碼示例

本文整理匯總了Java中android.view.KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE屬性的具體用法?Java KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE怎麽用?Java KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (event.getRepeatCount() == 0
            && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE)) {
        doPauseResume();
        show(sDefaultTimeout);
        if (mPauseButton != null)
            mPauseButton.requestFocus();
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) {
        if (mPlayer.isPlaying()) {
            mPlayer.pause();
            updatePausePlay();
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_BACK
            || keyCode == KeyEvent.KEYCODE_MENU) {
        hide();
        return true;
    } else {
        show(sDefaultTimeout);
    }
    return super.dispatchKeyEvent(event);
}
 
開發者ID:pili-engineering,項目名稱:PLDroidShortVideo,代碼行數:26,代碼來源:MediaController.java

示例2: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    PlaybackOverlayFragment playbackOverlayFragment = (PlaybackOverlayFragment) getFragmentManager().findFragmentById(R.id.playback_controls_fragment);
    switch (keyCode) {
        case KeyEvent.KEYCODE_MEDIA_PLAY:
            playbackOverlayFragment.togglePlayback(false);
            return true;
        case KeyEvent.KEYCODE_MEDIA_PAUSE:
            playbackOverlayFragment.togglePlayback(false);
            return true;
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
            if (mPlaybackState == LeanbackPlaybackState.PLAYING) {
                playbackOverlayFragment.togglePlayback(false);
            } else {
                playbackOverlayFragment.togglePlayback(true);
            }
            return true;
        default:
            return super.onKeyUp(keyCode, event);
    }
}
 
開發者ID:cleaninsights,項目名稱:cleaninsights-android-sdk,代碼行數:21,代碼來源:PlaybackOverlayActivity.java

示例3: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (event.getRepeatCount() == 0 && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE)){
        doPauseResume();
        show(sDefaultTimeout);
        if (mIbPause != null && mTvPlay != null){
            mIbPause.requestFocus();
            mTvPlay.requestFocus();
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP){
        if (mPlayerListener.isPlaying()){
            mPlayerListener.pause();
            updatePausePlay();
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU){
        hide();
        return true;
    } else
        show(sDefaultTimeout);
    return super.dispatchKeyEvent(event);
}
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:24,代碼來源:MediaController.java

示例4: onReceive

@Override
public void onReceive(Context context, Intent intent) {

    Log.d("Finaly i recived it","");
    if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
        final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);

        if (event != null && event.getAction() == KeyEvent.ACTION_DOWN) {
            switch (event.getKeyCode()) {
                case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                    Log.d("In keycode","");
                    break;
            }
        }
    }
}
 
開發者ID:mdnafiskhan,項目名稱:Mp3Player,代碼行數:16,代碼來源:MediaButtonReciver.java

示例5: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  int keyCode = event.getKeyCode();
  if (event.getRepeatCount() == 0 && (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE)) {
    doPauseResume();
    show(sDefaultTimeout);
    if (mPauseButton != null)
      mPauseButton.requestFocus();
    return true;
  } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP) {
    if (mPlayer.isPlaying()) {
      mPlayer.pause();
      updatePausePlay();
    }
    return true;
  } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
    hide();
    return true;
  } else {
    show(sDefaultTimeout);
  }
  return super.dispatchKeyEvent(event);
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:23,代碼來源:MediaController.java

示例6: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
            keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
            keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
            keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
            keyCode != KeyEvent.KEYCODE_MENU &&
            keyCode != KeyEvent.KEYCODE_CALL &&
            keyCode != KeyEvent.KEYCODE_ENDCALL;
    if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
        if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
                keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();
                mMediaController.show();
            } else {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
            if (!mMediaPlayer.isPlaying()) {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
                || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();
                mMediaController.show();
            }
            return true;
        } else {
            toggleMediaControlsVisiblity();
        }
    }

    return super.onKeyDown(keyCode, event);
}
 
開發者ID:WeDevelopTeam,項目名稱:HeroVideo-master,代碼行數:40,代碼來源:MediaPlayerView.java

示例7: onReceive

@Override
public void onReceive(Context context, Intent intent) {
	if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
		final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);

		if (event != null && event.getAction() == KeyEvent.ACTION_DOWN) {
			switch (event.getKeyCode()) {
				case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
					context.startService(new Intent(context, PlayerService.class));
					break;
			}
		}
	}
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:14,代碼來源:RemoteControlReceiver.java

示例8: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
            keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
            keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
            keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
            keyCode != KeyEvent.KEYCODE_MENU &&
            keyCode != KeyEvent.KEYCODE_CALL &&
            keyCode != KeyEvent.KEYCODE_ENDCALL;
    if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
        if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
                keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();
                mMediaController.show();
            } else {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
            if (!mMediaPlayer.isPlaying()) {
                start();
                mMediaController.hide();
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
                || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
            if (mMediaPlayer.isPlaying()) {
                pause();
                mMediaController.show();
            }
            return true;
        } else {
            toggleMediaControlsVisiblity();
        }
    }
    return super.onKeyDown(keyCode, event);
}
 
開發者ID:wheat7,項目名稱:VRPlayer,代碼行數:39,代碼來源:PlayerView.java

示例9: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
  boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK && keyCode != KeyEvent.KEYCODE_VOLUME_UP && keyCode != KeyEvent.KEYCODE_VOLUME_DOWN && keyCode != KeyEvent.KEYCODE_MENU && keyCode != KeyEvent.KEYCODE_CALL && keyCode != KeyEvent.KEYCODE_ENDCALL;
  if (isInPlaybackState() && isKeyCodeSupported && mMediaController != null) {
    if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE || keyCode == KeyEvent.KEYCODE_SPACE) {
      if (mMediaPlayer.isPlaying()) {
        pause();
        mMediaController.show();
      } else {
        start();
        mMediaController.hide();
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
      if (!mMediaPlayer.isPlaying()) {
          start();
          mMediaController.hide();
      }
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
      if (mMediaPlayer.isPlaying()) {
        pause();
        mMediaController.show();
      }
      return true;
    } else {
      toggleMediaControlsVisiblity();
    }
  }

  return super.onKeyDown(keyCode, event);
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:32,代碼來源:VideoView.java

示例10: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
        case KeyEvent.KEYCODE_MEDIA_NEXT:
        case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
            launchGlobalResume();
            return true;
    }
    return super.onKeyUp(keyCode, event);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:11,代碼來源:MainActivity.java

示例11: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    mApp = (Common) context.getApplicationContext();
    if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON)) {
        KeyEvent keyEvent = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT);
        if (keyEvent.getAction() != KeyEvent.ACTION_DOWN)
            return;
        switch (keyEvent.getKeyCode()) {
            case KeyEvent.KEYCODE_HEADSETHOOK:
                mApp.getPlayBackStarter().playSongs();
                break;
            case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                mApp.getPlayBackStarter().pauseSong();
                break;
            case KeyEvent.KEYCODE_MEDIA_PLAY:
                mApp.getPlayBackStarter().playSongs();
                break;
            case KeyEvent.KEYCODE_MEDIA_PAUSE:
                mApp.getPlayBackStarter().pauseSong();
                break;
            case KeyEvent.KEYCODE_MEDIA_STOP:
                mApp.getPlayBackStarter().pauseSong();
                break;
            case KeyEvent.KEYCODE_MEDIA_NEXT:
                mApp.getPlayBackStarter().nextSong();
                break;
            case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                mApp.getPlayBackStarter().previousSong();
                break;
            default:
                break;
        }
    }
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:34,代碼來源:HeadsetNotificationBroadcast.java

示例12: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
            keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
            keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
            keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
            keyCode != KeyEvent.KEYCODE_MENU &&
            keyCode != KeyEvent.KEYCODE_CALL &&
            keyCode != KeyEvent.KEYCODE_ENDCALL;
    if (isInPlaybackState() && isKeyCodeSupported && mController != null) {
        if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
                keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
            if (isPlaying()) {
                pause();
                //                    mController.setVisibility(VISIBLE);
            } else {
                start();
                //                    mController.setVisibility(GONE);
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
            if (!isPlaying()) {
                start();
                //                    mController.setVisibility(GONE);
            }
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
                || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
            if (isPlaying()) {
                pause();
                //                    mController.setVisibility(VISIBLE);
            }
            return true;
        } else {
            //                toggleMediaControlsVisiblity();
        }
    }

    return super.onKeyDown(keyCode, event);
}
 
開發者ID:SethWen,項目名稱:GestureVideoView,代碼行數:40,代碼來源:GestureVideoView.java

示例13: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (mPlayerCtrl == null) {
        return true;
    }

    int keyCode = event.getKeyCode();
    final boolean uniqueDown = event.getRepeatCount() == 0
            && event.getAction() == KeyEvent.ACTION_DOWN;
    if (keyCode ==  KeyEvent.KEYCODE_HEADSETHOOK
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
            || keyCode == KeyEvent.KEYCODE_SPACE) {
        if (uniqueDown) {
            doPauseResume();
            show(DEFTIMEOUT);
            if (mBtnPause != null) {
                mBtnPause.requestFocus();
            }
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
        if (uniqueDown && !mPlayerCtrl.isPlaying()) {
            mPlayerCtrl.start();
            updatePausePlay();
            show(DEFTIMEOUT);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
            || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
        if (uniqueDown && mPlayerCtrl.isPlaying()) {
            mPlayerCtrl.pause();
            updatePausePlay();
            show(DEFTIMEOUT);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
            || keyCode == KeyEvent.KEYCODE_VOLUME_UP
            || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
        // don't show the controls for volume adjustment
        return super.dispatchKeyEvent(event);
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
        if (uniqueDown) {
            hide();
        }
        return true;
    }

    show(DEFTIMEOUT);
    return super.dispatchKeyEvent(event);
}
 
開發者ID:natjs,項目名稱:nat-media-video,代碼行數:50,代碼來源:Controller.java

示例14: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON)) {
        if (intent.getExtras() == null) {
            return;
        }
        KeyEvent keyEvent = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT);
        if (keyEvent == null) {
            return;
        }
        if (keyEvent.getAction() != KeyEvent.ACTION_DOWN)
            return;

        switch (keyEvent.getKeyCode()) {
            case KeyEvent.KEYCODE_HEADSETHOOK:
            case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                if (MediaController.getInstance().isAudioPaused()) {
                    MediaController.getInstance().playAudio(MediaController.getInstance().getPlayingMessageObject());
                } else {
                    MediaController.getInstance().pauseAudio(MediaController.getInstance().getPlayingMessageObject());
                }
                break;
            case KeyEvent.KEYCODE_MEDIA_PLAY:
                MediaController.getInstance().playAudio(MediaController.getInstance().getPlayingMessageObject());
                break;
            case KeyEvent.KEYCODE_MEDIA_PAUSE:
                MediaController.getInstance().pauseAudio(MediaController.getInstance().getPlayingMessageObject());
                break;
            case KeyEvent.KEYCODE_MEDIA_STOP:
                break;
            case KeyEvent.KEYCODE_MEDIA_NEXT:
                MediaController.getInstance().playNextMessage();
                break;
            case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                MediaController.getInstance().playPreviousMessage();
                break;
        }
    } else {
        if (intent.getAction().equals(MusicPlayerService.NOTIFY_PLAY)) {
            MediaController.getInstance().playAudio(MediaController.getInstance().getPlayingMessageObject());
        } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_PAUSE) || intent.getAction().equals(android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
            MediaController.getInstance().pauseAudio(MediaController.getInstance().getPlayingMessageObject());
        } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_NEXT)) {
            MediaController.getInstance().playNextMessage();
        } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_CLOSE)) {
            MediaController.getInstance().cleanupPlayer(true, true);
        } else if (intent.getAction().equals(MusicPlayerService.NOTIFY_PREVIOUS)) {
            MediaController.getInstance().playPreviousMessage();
        }
    }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:51,代碼來源:MusicPlayerReceiver.java

示例15: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (mPlayer == null) {
        return true;
    }

    int keyCode = event.getKeyCode();
    final boolean uniqueDown = event.getRepeatCount() == 0
            && event.getAction() == KeyEvent.ACTION_DOWN;
    if (keyCode ==  KeyEvent.KEYCODE_HEADSETHOOK
            || keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
            || keyCode == KeyEvent.KEYCODE_SPACE) {
        if (uniqueDown) {
            doPauseResume();
            show(sDefaultTimeout);
            if (mPauseButton != null) {
                mPauseButton.requestFocus();
            }
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
        if (uniqueDown && !mPlayer.isPlaying()) {
            mPlayer.start();
            updatePausePlay();
            show(sDefaultTimeout);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
            || keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
        if (uniqueDown && mPlayer.isPlaying()) {
            mPlayer.pause();
            updatePausePlay();
            show(sDefaultTimeout);
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN
            || keyCode == KeyEvent.KEYCODE_VOLUME_UP
            || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) {
        // don't show the controls for volume adjustment
        return super.dispatchKeyEvent(event);
    } else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) {
        if (uniqueDown) {
            hide();
        }
        return true;
    }

    show(sDefaultTimeout);
    return super.dispatchKeyEvent(event);
}
 
開發者ID:mo3rfan,項目名稱:syncplayer,代碼行數:50,代碼來源:VideoControllerView.java


注:本文中的android.view.KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。