These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaPlayer pause method.
* Processes a request to pause the current playback */ protected void processPauseRequest() { if (mState == State.PLAYING) { mState = State.PAUSED; mPlayer.pause(); releaseResources(false); // retain media player in pause // TODO polite audio focus, instead of keep it owned; or not? } } /** * Processes a request to stop the playback. * * @param force When 'true', the playback is stopped no matter the value of mState */ protected void processStopRequest(boolean force) { if (mState != State.PREPARING || force) { mState = State.STOPPED;
pauseMusic(); drumbassPlaying = false; cScore = 0; andrModAmt = 10; if (drumbass!=null) drumbass.seekTo(0); if (androidpad!=null) androidpad.seekTo(0); } static void playSound(int soundKey, float volume, float pitch) { if (soundEnabled && mSoundPoolMap!=null) { Integer soundID = mSoundPoolMap.get(soundKey); if (soundID!=null) { mSoundPool.play(soundID, volume, volume, 1, 0, pitch); } } } public static void playScore() { //prevent repeated dings while (currentDing == prevDing) {
return true; } if ((keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD || keyCode == KeyEvent.KEYCODE_MEDIA_NEXT) && isMediaPlayerStateValid()) { int skipOffset = 10000 + mediaPlayer.getCurrentPosition(); int duration = mediaPlayer.getDuration(); if (skipOffset > duration) { skipOffset = duration - 1; } if (!mediaController.isShowing()) { mediaController.show(CONTROLLER_DELAY); } mediaPlayer.seekTo(skipOffset); return true; } if ((keyCode == KeyEvent.KEYCODE_MEDIA_REWIND || keyCode == KeyEvent.KEYCODE_MEDIA_PREVIOUS) && isMediaPlayerStateValid()) { int skipOffset = mediaPlayer.getCurrentPosition() - 10000;
Toast.LENGTH_LONG).show(); } } public void onPauseButton(View view) { if (mMediaPlayer.isPlaying()) { mMediaPlayer.pause(); } } public void onStopButton(View view) { if (!mMediaPlayer.isPlaying()) { return; } mMediaPlayer.stop(); isPrepared = false; // もう一度再生されるために準備しておく try { // prepareAsync()ではなくてprepare()を呼ぶと // stopping状態にprepare()が要求されて
mp.release(); } public static void preparePauseRelease(String filePath) throws Exception { Log.v(TAG, "preparePauseRelease" + filePath); MediaPlayer mp = new MediaPlayer(); mp.setDataSource(filePath); mp.prepare(); mp.pause(); mp.release(); } static MediaPlayer.OnVideoSizeChangedListener mOnVideoSizeChangedListener = new MediaPlayer.OnVideoSizeChangedListener() { public void onVideoSizeChanged(MediaPlayer mp, int width, int height) { synchronized (videoSizeChanged) { Log.v(TAG, "sizechanged notification received ..."); videoSizeChanged.notify(); } }
} if (mState == State.Playing) { // Pause media player and cancel the 'foreground service' state. mState = State.Paused; mPlayer.pause(); relaxResources(false); // while paused, we always retain the MediaPlayer // do not give up audio focus } // Tell any remote controls that our playback state is 'paused'. if (mRemoteControlClientCompat != null) { mRemoteControlClientCompat .setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED); } } void processRewindRequest() { if (mState == State.Playing || mState == State.Paused) mPlayer.seekTo(0);
this.mIsPaused = false; } } public void pauseBackgroundMusic(){ if (mBackgroundMediaPlayer != null && mBackgroundMediaPlayer.isPlaying()){ mBackgroundMediaPlayer.pause(); this.mIsPaused = true; } } public void resumeBackgroundMusic(){ if (mBackgroundMediaPlayer != null && this.mIsPaused){ mBackgroundMediaPlayer.start(); this.mIsPaused = false; } } public void rewindBackgroundMusic(){ if (mBackgroundMediaPlayer != null){
public static void globalPauseSound() { if(mSoundPool != null) mSoundPool.autoPause(); if(mPlayer != null && mPlayer.isPlaying()) mPlayer.pause(); } public static void globalResumeSound() { if(mSoundPool != null) mSoundPool.autoResume(); if(mPlayer != null) mPlayer.start(); } public static void cleanup() {
90: if(mp!=null){
91: mp.pause();
92: // Changing button image to play button
93: btnPlay.setImageResource(R.drawable.btn_play);
94: }