Best code examples for MediaPlayer setDataSource method (android.media.MediaPlayer.setDataSource)

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

MediaPlayer setDataSource examples from Open Source projects
This code example shows how to use the following methods: setDataSource, invoke, newRequest
61:	mPlayer.setDataSource("test:invoke_mock_media_player.so?url=ping"); 
-
63:	Parcel request = mPlayer.newRequest(); 
-
68:	mPlayer.invoke(request, reply); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: isPlaying, prepare, setAudioStreamType, setDataSource, start
151:	return player != null && player.isPlaying(); 
-
184:	player.setDataSource(s); 
185:	player.setAudioStreamType(AudioManager.STREAM_MUSIC); 
186:	player.prepare(); 
-
191:	player.start(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getDuration, prepare, release, setDataSource
135:	mPlayer = new MediaPlayer(); 
136:	mPlayer.setDataSource("/sdcard/" + file); 
137:	mPlayer.prepare(); 
138:	duration = mPlayer.getDuration(); 
139:	mPlayer.release(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: prepare, setAudioStreamType, setDataSource
39:	mp = new MediaPlayer(); 
40:	mp.setDataSource( afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); 
41:	mp.setAudioStreamType(AudioManager.STREAM_MUSIC); 
42:	mp.prepare(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: prepare, setDataSource, setVolume
25:	player = new MediaPlayer(); 
26:	player.setDataSource(fileName); 
27:	player.prepare(); 
-
91:	if(player!=null) player.setVolume(leftVolume, rightVolume); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: getDuration, prepare, release, setDataSource
128:	mPlayer = new MediaPlayer(); 
129:	mPlayer.setDataSource("/sdcard/" + file); 
130:	mPlayer.prepare(); 
131:	duration = mPlayer.getDuration(); 
132:	mPlayer.release(); 
Full Snippet Info
7
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
6
CodeRank
This code example shows how to use the following methods: isPlaying, prepare, reset, setDataSource, start
24:	if (!mediaPlayer.isPlaying() && currentTrack != null) { 
-
27:	mediaPlayer.reset(); 
28:	mediaPlayer.setDataSource(currentTrack); 
29:	mediaPlayer.prepare(); 
-
32:	mediaPlayer.start(); 
Full Snippet Info
6
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: isPlaying, prepare, setAudioStreamType, setDataSource, setLooping
72:	if(!player.isPlaying()) { 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: prepare, setAudioStreamType, setDataSource
39:	mp = new MediaPlayer(); 
40:	mp.setDataSource( afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); 
41:	mp.setAudioStreamType(AudioManager.STREAM_MUSIC); 
42:	mp.prepare(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: prepare, setAudioStreamType, setDataSource, setOnCompletionListener, start
57:	MediaPlayer mediaPlayer = new MediaPlayer(); 
-
59:	mediaPlayer.setDataSource(context, 
-
70:	mediaPlayer.setAudioStreamType(AudioManager.STREAM_NOTIFICATION); 
-
72:	mediaPlayer.prepare(); 
-
78:	mediaPlayer.start(); 
79:	mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: prepare, setDataSource
45:	mediaPlayer = new MediaPlayer(); 
-
54:	mediaPlayer.setDataSource(temp.getAbsolutePath()); 
55:	mediaPlayer.prepare(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAudioStreamType, setDataSource, setLooping, setOnErrorListener
61:	MediaPlayer newPlayer = new MediaPlayer(); 
-
64:	newPlayer.setOnErrorListener(playerErrorListener); 
65:	newPlayer.setDataSource(context, ringtoneUri); 
66:	newPlayer.setLooping(true); 
67:	newPlayer.setAudioStreamType(AudioManager.STREAM_RING); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: prepare, setAudioStreamType, setDataSource, setLooping, start
100:	mPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); 
-
103:	mPlayer.setDataSource(this, url); 
104:	mPlayer.prepare(); 
105:	mPlayer.setLooping(true); 
106:	mPlayer.start(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: prepareAsync, setDataSource
73:	mMediaPlayer.setDataSource(mAudioTrackURL); 
74:	mMediaPlayer.prepareAsync(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getDuration, prepare, release, setDataSource
135:	mPlayer = new MediaPlayer(); 
136:	mPlayer.setDataSource("/sdcard/" + file); 
137:	mPlayer.prepare(); 
138:	duration = mPlayer.getDuration(); 
139:	mPlayer.release(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: prepare, setDataSource, setOnCompletionListener, setVolume, start
52:	player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { 
-
58:	player.setDataSource(file.getFileDescriptor(), file.getStartOffset(), file.getLength()); 
-
60:	player.setVolume(0.2f, 0.2f); 
61:	player.prepare(); 
62:	player.start(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: prepare, release, setDataSource, start, stop
51:	MediaPlayer mp = new MediaPlayer(); 
52:	mp.setDataSource(filePath); 
53:	mp.prepare(); 
54:	mp.start(); 
55:	Thread.sleep(200000); 
56:	mp.stop(); 
57:	mp.release(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: prepare, setDataSource, setVolume
140:	mediaPlayer = new MediaPlayer(); 
141:	mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), 
-
143:	mediaPlayer.prepare(); 
-
145:	mediaPlayer.setVolume(mLeftVolume, mRightVolume); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getDuration, getVideoHeight, getVideoWidth, prepare, setDataSource
174:	MediaPlayer player = new MediaPlayer(); 
-
176:	player.setDataSource(filePath); 
177:	player.prepare(); 
178:	obj.put("duration", player.getDuration() / 1000); 
-
180:	obj.put("height", player.getVideoHeight()); 
181:	obj.put("width", player.getVideoWidth()); 
Full Snippet Info
8
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: 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: isPlaying, prepare, reset, setDataSource, start
70:	if (mPlayer.isPlaying()) 
71:	mPlayer.stop(); 
72:	mPlayer.reset(); 
-
77:	mPlayer.setDataSource(mFile); 
78:	mPlayer.prepare(); 
79:	mPlayer.start(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: prepareAsync, release, reset, setDataSource
592:	MediaPlayer mp = new MediaPlayer(); 
593:	mp.setDataSource(filePath); 
594:	mp.prepareAsync(); 
595:	mp.reset(); 
596:	mp.release(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: prepare, setDataSource, setOnCompletionListener, setOnErrorListener, start
214:	mPlayer = new MediaPlayer(); 
-
216:	mPlayer.setDataSource(mSampleFile.getAbsolutePath()); 
217:	mPlayer.setOnCompletionListener(this); 
218:	mPlayer.setOnErrorListener(this); 
219:	mPlayer.prepare(); 
220:	mPlayer.start(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setDataSource, invoke, newRequest
61:	mPlayer.setDataSource("test:invoke_mock_media_player.so?url=ping"); 
-
63:	Parcel request = mPlayer.newRequest(); 
-
68:	mPlayer.invoke(request, reply); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: prepare, reset, setDataSource, start, stop
38:	player.stop(); 
-
40:	player.reset(); 
-
42:	player.setDataSource(mp3); 
43:	player.prepare(); 
-
45:	player.start(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition, prepareAsync, reset, setDataSource, stop
289:	player.setDataSource(path); 
-
302:	player.prepareAsync(); 
-
352:	player.stop(); 
-
370:	player.reset(); 
-
412:	res = player.getCurrentPosition(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: prepare, setDataSource, setOnCompletionListener, setOnPreparedListener, setOnSeekCompleteListener
19:	mediaPlayer = new MediaPlayer(); 
-
21:	mediaPlayer.setDataSource(assetDescriptor.getFileDescriptor(), 
-
24:	mediaPlayer.prepare(); 
-
26:	mediaPlayer.setOnCompletionListener(this); 
27:	mediaPlayer.setOnSeekCompleteListener(this); 
28:	mediaPlayer.setOnPreparedListener(this); 
29:	mediaPlayer.setOnVideoSizeChangedListener(this); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: prepare, setDataSource
42:	player = new MediaPlayer(); 
-
44:	player.setDataSource(path); 
45:	player.prepare(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getDuration, prepare, release, setDataSource
78:	MediaPlayer a= new MediaPlayer(); 
-
80:	a.setDataSource(context, videoUri); 
81:	a.prepare(); 
82:	int result = a.getDuration(); 
83:	a.release(); 
-
86:	a.release(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCurrentPosition, prepare, reset, seekTo, setDataSource
54:	int pos = mp.getCurrentPosition(); 
55:	mp.reset(); 
-
57:	mp.setDataSource(ctx, video); 
58:	mp.prepare(); 
59:	mp.start(); 
-
69:	mp.seekTo(pos); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: prepare, release, setDataSource, start, stop
51:	MediaPlayer mp = new MediaPlayer(); 
52:	mp.setDataSource(filePath); 
53:	mp.prepare(); 
54:	mp.start(); 
55:	Thread.sleep(200000); 
56:	mp.stop(); 
57:	mp.release(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: prepare, reset, setAudioStreamType, setDataSource, setLooping
53:	MediaPlayer mp = new MediaPlayer(); 
-
59:	mp.reset(); 
60:	mp.setAudioStreamType(AudioManager.STREAM_MUSIC); 
61:	mp.setLooping(true); 
62:	mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength()); 
63:	mp.prepare(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: prepare, setDataSource
23:	mp = new MediaPlayer(); 
-
25:	mp.setDataSource(Path); 
26:	mp.prepare(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: prepareAsync, setDataSource, setLooping, setOnPreparedListener
45:	_mp = new MediaPlayer(); 
-
47:	_mp.setDataSource(uri); 
-
51:	_mp.setDataSource(uri); 
52:	_mp.setOnPreparedListener(this); 
53:	_mp.prepareAsync(); 
-
55:	_mp.setLooping(true); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setDataSource, invoke, newRequest
61:	mPlayer.setDataSource("test:invoke_mock_media_player.so?url=ping"); 
-
63:	Parcel request = mPlayer.newRequest(); 
-
68:	assertEquals(0, mPlayer.invoke(request, reply)); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: prepare, setDataSource
60:	mediaPlayer = new MediaPlayer(); 
61:	mediaPlayer.setDataSource(path); 
62:	mediaPlayer.prepare(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: prepare, setDataSource
22:	mediaPlayer = new MediaPlayer(); 
-
29:	mediaPlayer.setDataSource(song.getAbsolutePath()); 
30:	mediaPlayer.prepare(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: prepare, reset, setDataSource, setLooping, setVolume
49:	mp.reset(); 
50:	mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength()); 
51:	mp.prepare(); 
52:	mp.setVolume(0.5f, 0.5f); 
53:	mp.setLooping(repeat); 
54:	mp.start(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getDuration, prepare, release, setDataSource
302:	MediaPlayer mp = new MediaPlayer(); 
303:	mp.setDataSource(recorded_file); 
304:	mp.prepare(); 
305:	int duration = mp.getDuration(); 
-
309:	mp.release(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: prepare, setDataSource
22:	mediaPlayer = new MediaPlayer(); 
-
29:	mediaPlayer.setDataSource(song.getAbsolutePath()); 
30:	mediaPlayer.prepare(); 
Full Snippet Info
7
CodeRank
Related MediaPlayer setDataSource Questions & Answers:
Other MediaPlayer setDataSource Examples
236:				}
237:			});
238:	
239:			/**
240:			 * Button Click event for Play list click event

Read More

setDataSource Method Overview
Sets the data source (file-path or http/rtsp URL) to use.
See Also