Best code examples for Android MediaPlayer class (android.media.MediaPlayer)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android MediaPlayer class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android MediaPlayer examples from Open Source projects
This code example shows how to use the following methods: release, stop
122:	mp.stop(); 
123:	mp.release(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: isPlaying, release, stop
81:	if (mMediaPlayer.isPlaying()) { 
82:	mMediaPlayer.stop(); 
-
84:	mMediaPlayer.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: release, stop
43:	player.release(); 
-
73:	player.stop(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
48:	mPlayer = new MediaPlayer(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: isPlaying, stop
40:	if (player.isPlaying()) { 
41:	player.stop(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: isLooping, isPlaying, pause, release, seekTo
75:	if ( mp.isLooping() || mp.isPlaying() ) 
-
78:	mp.pause(); 
79:	mp.seekTo(0); 
-
91:	mp.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: prepare, prepareAsync, setAudioStreamType, setDataSource, setOnPreparedListener
77:	mPlayer = new MediaPlayer(); 
-
84:	mPlayer.setDataSource(file); 
85:	mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 
86:	mPlayer.prepareAsync(); 
-
90:	mPlayer.setDataSource("/sdcard/" + file); 
91:	mPlayer.prepare(); 
-
93:	mPlayer.setOnPreparedListener(this); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: prepareAsync, setAudioStreamType, setDataSource, setOnCompletionListener, setOnPreparedListener
87:	mediaPlayer = new MediaPlayer(); 
88:	mediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL); 
89:	mediaPlayer.setOnCompletionListener(this); 
90:	mediaPlayer.setOnPreparedListener(this); 
-
96:	mediaPlayer.setDataSource(context, dataUri); 
-
114:	mediaPlayer.prepareAsync(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: isPlaying, setAudioStreamType, setDataSource, setLooping, setOnErrorListener
96:	if(!player.isPlaying()) { 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: isPlaying, release, stop
39:	if (mediaPlayer.isPlaying()) { 
40:	mediaPlayer.stop(); 
-
42:	mediaPlayer.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: isPlaying
82:	return (fileName.equals(currentTrack) && mediaPlayer.isPlaying()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: prepare, setDataSource, start
62:	MediaPlayer mediaPlayer = new MediaPlayer(); 
-
65:	mediaPlayer.setDataSource(file); 
66:	mediaPlayer.prepare(); 
67:	mediaPlayer.start(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods:
48:	mPlayer = new MediaPlayer(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: isPlaying, stop
174:	if (mMediaPlayer.isPlaying()) 
-
176:	mMediaPlayer.stop(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: setAudioStreamType, setOnBufferingUpdateListener, setOnCompletionListener, setOnErrorListener, setOnPreparedListener
22:	mMediaPlayer = new MediaPlayer(); 
23:	mMediaPlayer.setOnBufferingUpdateListener(this); 
24:	mMediaPlayer.setOnCompletionListener(this); 
25:	mMediaPlayer.setOnPreparedListener(this); 
26:	mMediaPlayer.setOnErrorListener(this); 
27:	mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: stop
39:	player.stop(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: release, stop
153:	mPlayer.stop(); 
154:	mPlayer.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: isPlaying, release, stop
57:	mp.stop(); 
58:	mp.release(); 
-
66:	if (mp.isPlaying()) 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: release, stop
80:	mMediaPlayer.stop(); 
81:	mMediaPlayer.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: isPlaying, release, stop
117:	if (player.isPlaying()) { 
118:	player.stop(); 
-
120:	player.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: release, stop
86:	mCurrentMediaPlayer.stop(); 
87:	mCurrentMediaPlayer.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: isPlaying, release, stop
30:	if (mediaPlayer.isPlaying()) 
31:	mediaPlayer.stop(); 
32:	mediaPlayer.release(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: release, stop
239:	mPlayer.stop(); 
240:	mPlayer.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: isPlaying, release, stop
150:	if (mediaPlayer.isPlaying()) { 
-
152:	mediaPlayer.stop(); 
-
155:	mediaPlayer.release(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: release, stop
57:	mMediaPlayer.stop(); 
58:	mMediaPlayer.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: isPlaying, release, stop
111:	if (mMediaPlayer.isPlaying()) { 
112:	mMediaPlayer.stop(); 
-
114:	mMediaPlayer.release(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: isPlaying, release, stop
96:	if (player.isPlaying()) { 
97:	player.stop(); 
-
99:	player.release(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: release, stop
81:	mp.stop(); 
82:	mp.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: release, stop
320:	mPlayer.stop(); 
321:	mPlayer.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: release, stop
337:	mp.stop(); 
-
341:	mp.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: release, stop
96:	mp.stop(); 
-
107:	mp.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: release, stop
333:	mMediaPlayer.stop(); 
334:	mMediaPlayer.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: release, stop
32:	mediaPlayer.stop(); 
33:	mediaPlayer.release(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: release, stop
96:	mp.stop(); 
-
107:	mp.release(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: release, stop
103:	mPlayer.stop(); 
104:	mPlayer.release(); 
Full Snippet Info
8
CodeRank
Related Android MediaPlayer Questions & Answers:
Other Android MediaPlayer Examples
11:	
12:	            @Override
13:	            public void onCompletion(MediaPlayer mp) {
14:	                // TODO Auto-generated method stub
15:	                mp.release();

Read More

4:		@Override
5:		public void onCompletion(MediaPlayer arg0) {
6:	
7:			// check for repeat is ON or OFF
8:			if(isRepeat){

Read More

21:		private boolean hasFlash;
22:		Parameters params;
23:		MediaPlayer mp;
24:	
25:		@Override
-
144:	
145:	            @Override
146:	            public void onCompletion(MediaPlayer mp) {
147:	                // TODO Auto-generated method stub
148:	                mp.release();

Read More

See Code Examples for Android MediaPlayer Methods: