MediaPlayer pause - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaPlayer pause method.

This code example shows how to use the following methods:isLooping, isPlaying, pause, seekTo
		} 
	} 
	 
	public void stop() throws IOException 
	{ 
		if ( mp.isLooping() || mp.isPlaying() )
		{ 
			state = INVALID;
			mp.pause();
			mp.seekTo(0);
		} 
	} 
	 
	public void loop() throws IOException 
	{ 
		invokePlay( true ); 
	} 
	 
	public void unload() throws IOException 
	{ 
10
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:pause, release, reset
     * 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;

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isPlaying, pause, seekTo
    	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) {

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getCurrentPosition, getDuration, isPlaying, pause, seekTo
			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;

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isPlaying, pause
                           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()が要求されて 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:pause
    public void pausePlayback() { 
        if (mPlayer == null) {
            return; 
        } 
 
        mPlayer.pause();
        setState(PLAYING_PAUSED_STATE);
    } 
 
    public void stopPlayback() { 
        if (mPlayer == null) // we were not in playback
            return; 
 
        mPlayer.stop();
        mPlayer.release();
        mPlayer = null;
        setState(IDLE_STATE);
    } 
 
    public void stop() { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:pause, prepare, release, setDataSource
        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(); 
                } 
            } 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:pause, release, reset
        } 
 
        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);

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isPlaying, pause
			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){
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isPlaying, pause
	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() 
	{ 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related MediaPlayer pause Questions & Answers:

Other MediaPlayer pause Examples

90:						if(mp!=null){
91:							mp.pause();
92:							// Changing button image to play button
93:							btnPlay.setImageResource(R.drawable.btn_play);
94:						}

Read More

pause Method Overview
Pauses playback.
See Code Examples for other Android MediaPlayer Methods: