MediaPlayer stop - 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 stop method.

This code example shows how to use the following methods:release, stop
	 * @param mp 
	 */ 
	private void safeClose(MediaPlayer mp) {
		if (mp != null) {
			try { 
				mp.stop();
			} catch (Exception e) {
				Log.w(TAG, "Failed to stop media player",e);
			} finally { 
				mp.release();
			} 
		} 
	} 
	 
	/** 
	 * Safely close a {@link MediaRecorder} without throwing 
	 * exceptions 
	 * @param mr 
	 */ 
	private void safeClose(MediaRecorder mr, boolean stopIt) {
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:stop
		} 
	} 
	void stop(){ 
		if(stream){
			if(player==null) return;
			player.stop();
		}else if(streamID!=-1){
			pool.stop(streamID);
			bIsPlaying = false;
		} 
	} 
	 
	void setVolume(float vol){
		volume = vol;
		// calculates left/right volumes from pan-value (constant panning law)  
		// see: Curtis Roads: Computer Music Tutorial p 460 
		// thanks to jasch 
		float angle = pan * 0.7853981633974483f; // in radians from -45. to +45.
		float cosAngle = FloatMath.cos(angle);
		float sinAngle = FloatMath.sin(angle);
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isPlaying, release, stop
            throw new RuntimeException("Couldn't load music");
        } 
    } 
 
    public void dispose() { 
        if (mediaPlayer.isPlaying())
            mediaPlayer.stop();
        mediaPlayer.release();
    } 
 
    public boolean isLooping() { 
        return mediaPlayer.isLooping();
    } 
 
    public boolean isPlaying() { 
        return mediaPlayer.isPlaying();
    } 
 
    public boolean isStopped() { 
        return !isPrepared;
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:release, stop
    public void onCompletion(MediaPlayer mediaplayer) {
        Timer endSound = new Timer();
        endSound.schedule(new TimerTask() {
            public void run() { 
                if (mp != null) {
                    mp.stop();
                    mp.release();
                    mp = null;
                } 
            } 
        }, 200); 
 
    } 
 
    /** 
     * Play sound, either locally (from assets) or remotely via URL. 
     *  
     * @param soundUri 
     *            the sound uri 
     */ 
10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isPlaying, release, stop
	/** 
	 * Get rid of the music 
	 */ 
	public void dispose() { 
		 
		if (mediaPlayer.isPlaying()) {
			 
			mediaPlayer.stop();
		} 
		 
		mediaPlayer.release();
	} 
 
	/** 
	 * Called internal 
	 *  
	 * @param MediaPlayer mediaPlayer 
	 */ 
	public void onCompletion(MediaPlayer mediaPlayer) {
		 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:stop
        return false; 
    } 
 
    @Override 
    public void onCompletion(MediaPlayer player) {
        player.stop();
    } 
 
    @Override 
    public View getView() {
        return mVideoView;
    } 
 
    @Override 
    public ViewGroup getContainerView() {
        return mCustomView;
    } 
 
    @Override 
    public void navigate(String url) {
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isPlaying, stop
    } 
  } 
   
  @Override 
  public void onPause() { 
    if (player.isPlaying()) {
      player.stop();
    } 
     
    super.onPause(); 
  } 
   
  public void onPrepared(MediaPlayer player) {
    player.start();
  } 
} 
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isPlaying, release, stop
		} 
		return play;
	} 
	public static void cleanup() { 
		if (mMediaPlayer != null) {
			if (mMediaPlayer.isPlaying()) {
				mMediaPlayer.stop();
			} 
			mMediaPlayer.release();
			mMediaPlayer = null;
		} 
	} 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isPlaying, release, stop
            Log.v(TAG, "Tried to release player when it was already released");
            return; 
        } 
        try { 
            if (player != null) {
                if (player.isPlaying()) {
                    player.stop();
                } 
                player.release();
            } 
        } catch (Exception e) {
            Log.e(TAG, e.getMessage(), e);
        } 
        Log.v(TAG, "Released the music.");
        released = true;
    } 
 
    /** 
     * Sets the Volume level in sensible range. Handles special case of someone is calling or if on call. 
     * @param context 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:release, stop
		} 
	}  
 
	public void stopPlaying() { 
		if (isPlaying) {
			mPlayer.stop();
			mPlayer.release();
			isPlaying=false;
		} 
	} 
	 
	public void onCompletion(MediaPlayer mPlayer) {
		mPlayer.stop();
		mPlayer.release();
		isPlaying=false;
    }  
	 
	protected long getCurrentPosition() { 
		if (isPlaying) 
		{ 
10
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related MediaPlayer stop Questions & Answers:

stop Method Overview
Stops playback after playback has been stopped or paused.
See Code Examples for other Android MediaPlayer Methods: