Skip to content

Instantly share code, notes, and snippets.

@udacityandroid
Last active May 19, 2023 05:51
Show Gist options
  • Save udacityandroid/f4ec40027031ba7de9352465f143c816 to your computer and use it in GitHub Desktop.
Save udacityandroid/f4ec40027031ba7de9352465f143c816 to your computer and use it in GitHub Desktop.

Revisions

  1. udacityandroid renamed this gist May 13, 2016. 1 changed file with 0 additions and 0 deletions.
  2. udacityandroid created this gist May 13, 2016.
    16 changes: 16 additions & 0 deletions Helper Method - releaseMediaPlayer.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    /**
    * Clean up the media player by releasing its resources.
    */
    private void releaseMediaPlayer() {
    // If the media player is not null, then it may be currently playing a sound.
    if (mMediaPlayer != null) {
    // Regardless of the current state of the media player, release its resources
    // because we no longer need it.
    mMediaPlayer.release();

    // Set the media player back to null. For our code, we've decided that
    // setting the media player to null is an easy way to tell that the media player
    // is not configured to play an audio file at the moment.
    mMediaPlayer = null;
    }
    }