Forked from udacityandroid/Helper Method - releaseMediaPlayer()
Created
March 19, 2018 09:44
-
-
Save alaaaly85/043542c1dbbb48b062f24cede1c23f03 to your computer and use it in GitHub Desktop.
Miwok app: Cleaning up MediaPlayer resources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment