Android mediaplayer not progress seeking completely - android

Am trying to play a .wav file using media-player. Actually, I had done so far shown below. It's playing an updating the progress correctly but the problem media player is not seeking completely. Media-player stops giving out progress before the total duration of the file and stops updating progress. I have also implemented OnComplete listener also am not getting the callback. Here is my code can anyone spot me with where am missing.
public void playAudioFile() {
try {
mMediaPlayer.reset();
setMediaPlayerSource();
mMediaPlayer.prepare();
mMediaPlayer.start();
mMediaPlayer.setOnCompletionListener(new OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer arg0) {
Graphbar.setProgress(mMediaPlayer.getDuration());
}
});
bPlay.setBackgroundResource(R.drawable.pause_selector);
new Thread(new Runnable() {
#Override
public void run() {
System.out.println("Playing");
updateProgressBar();
}
}).start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void updateProgressBar() {
Graphbar.setProgress(0);
Graphbar.setMax(mMediaPlayer.getDuration());
mHandler.postDelayed(mUpdateTimeTask, 0);
}
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
if(mMediaPlayer.isPlaying()){
long totalDuration = Graphbar.getMax();
long currentDuration =mMediaPlayer.getCurrentPosition();
String TotalDur = Utilities.milliSecondsToTimer(totalDuration);
tvTimeRight.setText(TotalDur);
tvTimeLeft.setText(""+ Utilities.milliSecondsToTimer(currentDuration));
System.out.println(currentDuration+"/"+totalDuration);
Graphbar.setProgress((int)currentDuration);
mHandler.postDelayed(this, 1);
}
}
};
private void setMediaPlayerSource() {
String audioFile = getFilename();
try {
mMediaPlayer.setDataSource(audioFile);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

for total duration use mediaplayer.getduration. Remove unnecessary code from the runnable handler , because it will create load to ur seek bar . Because at every second u are calculating something and updating layout based on that calculation .
I would suggest you to use chronometer view of android.
public void playAudioFile() {
try {
mMediaPlayer.reset();
setMediaPlayerSource();
mMediaPlayer.prepare();
mMediaPlayer.start();
mMediaPlayer.setOnCompletionListener(new OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer arg0) {
Graphbar.setProgress(mMediaPlayer.getDuration());
}
});
bPlay.setBackgroundResource(R.drawable.pause_selector);
//set this only for once , because for one song total duration is always constant.
updateProgressBar();
}
public void updateProgressBar() {
Graphbar.setProgress(0);
Graphbar.setMax(mMediaPlayer.getDuration());
mHandler.postDelayed(mUpdateTimeTask, 0);
long totalDuration = mMediaPlayer.getDuration();
String TotalDur = Utilities.milliSecondsToTimer(totalDuration);
tvTimeRight.setText(TotalDur);
}
private Runnable mUpdateTimeTask = new Runnable() {
public void run() {
if(mMediaPlayer.isPlaying()){
//long totalDuration = mMediaPlayer.getDuration();=> no need of calculating total time and updating it to seekbar at every second
long currentDuration =mMediaPlayer.getCurrentPosition();
tvTimeLeft.setText(""+ Utilities.milliSecondsToTimer(currentDuration));
System.out.println(currentDuration+"/"+totalDuration);
Graphbar.setProgress((int)currentDuration);
mHandler.postDelayed(this, 1);
}
}
};
private void setMediaPlayerSource() {
String audioFile = getFilename();
try {
mMediaPlayer.setDataSource(audioFile);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

Related

It has just one issue that it plays multiple songs if selected, rest everything works fine

the issue is, I have checked whether media player is null or not, if not I have applied release() method but still when I select another song to play, it plays new song but it doesn't stop the previous one. While playing next or previous on click also works fine. so why it is not detecting that mediaplayer is playing.
here is java code.
public class Musicplay extends AppCompatActivity implements View.OnClickListener {
Button play,next,previous;
TextView songmar;
SeekBar seekBar;
MediaPlayer mediaPlayer;
int position,idr;
Handler handler=new Handler();
Handler vindler=new Handler();
Uri uri;
int max;
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.playdisplay);
Intent i=getIntent();
position=i.getIntExtra("position",0);
play=findViewById(R.id.pause);
next=findViewById(R.id.next);
previous=findViewById(R.id.previous);
songmar=findViewById(R.id.songnamemar);
songmar.setSelected(true);
songmar.setText(Musiclist.songname.get(position));
seekBar=findViewById(R.id.seekBar);
if(mediaPlayer==null)
{
Log.d("null","null");
}
else {
if(mediaPlayer.isPlaying())
{
mediaPlayer.stop();
mediaPlayer.release();
}
else {
mediaPlayer.release();
}
}
uri=Uri.parse(String.valueOf(new File(Musiclist.songpath.get(position))));
mediaPlayer=MediaPlayer.create(Musicplay.this,uri);
seekBar.setMax(mediaPlayer.getDuration());
mediaPlayer.start();
max=mediaPlayer.getDuration();
play.setBackgroundResource(R.drawable.ic_pause);
Thread thread=new Thread(){
#Override
public void run() {
super.run();
int currentposition=0;
while (currentposition<max)
{
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
currentposition=mediaPlayer.getCurrentPosition();
seekBar.setProgress(currentposition);
}
}
};
thread.start();
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
#Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
mediaPlayer.seekTo(seekBar.getProgress());
}
});
next.setOnClickListener(Musicplay.this);
play.setOnClickListener(Musicplay.this);
previous.setOnClickListener(Musicplay.this);
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mp) {
mp.stop();
mp.reset();
if(position<(Musiclist.songname.size()-1)){
position=position +1;
}
else
{
position=0;
}
uri = Uri.parse(String.valueOf(new File(Musiclist.songpath.get(position))));
try {
mp.setDataSource(Musicplay.this,uri);
} catch (IOException e) {
e.printStackTrace();
}
songmar.setText(Musiclist.songname.get(position));
songmar.setSelected(true);
try {
mp.prepare();
} catch (IOException e) {
e.printStackTrace();
}
}
});
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
mp.start();
seekBar.setMax(mp.getDuration());
max=mp.getDuration();
Log.d("seekvalue",String.valueOf(max));
}
});
}
#Override
public void onClick(View v) {
idr=v.getId();
Thread thread2=new Thread(){
#Override
public void run() {
super.run();
handler.post(new Runnable() {
#Override
public void run() {
switch (idr){
case R.id.pause:
if(mediaPlayer.isPlaying()){
mediaPlayer.pause();
play.setBackgroundResource(R.drawable.ic_play);
}
else {
play.setBackgroundResource(R.drawable.ic_pause);
mediaPlayer.start();
}
break;
case R.id.next:
mediaPlayer.stop();
mediaPlayer.reset();
if(position<(Musiclist.songname.size()-1)){
position=position +1;
Uri uri=Uri.parse(String.valueOf(new File(Musiclist.songpath.get(position))));
try {
mediaPlayer.setDataSource(Musicplay.this,uri);
} catch (IOException e) {
e.printStackTrace();
}
int a=0;
for(int i=0;i<150;i++)
{
a=a+1;
}
try {
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
play.setBackgroundResource(R.drawable.ic_pause);
songmar.setText(Musiclist.songname.get(position));
songmar.setSelected(true);
}
else {
position=0;
Uri uri=Uri.parse(String.valueOf(new File(Musiclist.songpath.get(position))));
try {
mediaPlayer.setDataSource(Musicplay.this,uri);
} catch (IOException e) {
e.printStackTrace();
}
int a=0;
for(int i=0;i<150;i++)
{
a=a+1;
}
try {
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
play.setBackgroundResource(R.drawable.ic_pause);
songmar.setText(Musiclist.songname.get(position));
songmar.setSelected(true);
}
break;
case R.id.previous:
mediaPlayer.stop();
mediaPlayer.reset();
if(position>0){
position=position-1;
Uri uri=Uri.parse(String.valueOf(new File(Musiclist.songpath.get(position))));
try {
mediaPlayer.setDataSource(Musicplay.this,uri);
} catch (IOException e) {
e.printStackTrace();
}
int a=0;
for(int i=0;i<150;i++)
{
a=a+1;
}
try {
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
play.setBackgroundResource(R.drawable.ic_pause);
songmar.setText(Musiclist.songname.get(position));
songmar.setSelected(true);
}
else {
position=Musiclist.songname.size()-1;
Uri uri=Uri.parse(String.valueOf(new File(Musiclist.songpath.get(position))));
try {
mediaPlayer.setDataSource(Musicplay.this,uri);
} catch (IOException e) {
e.printStackTrace();
}
int a=0;
for(int i=0;i<150;i++)
{
a=a+1;
}
try {
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
play.setBackgroundResource(R.drawable.ic_pause);
songmar.setText(Musiclist.songname.get(position));
songmar.setSelected(true);
}
break;
}
}
});
}
};
thread2.start();
}
}
so do suggest reason why this error is taking place, and it is playing two or multiple song simultaneously.
all you have to do is, just declare mediaplayer variable public static and when you start activity to play song just check for media player is null or not and then release it

Get Video Play Time android from videoplayer

I write this function to get video time . This functions works fine but when I backpress then it throws exception .
public void videoTimer ()
{
try
{
running = true;
final int duration = mVideoView.getDuration();
thread = new Thread(new Runnable()
{
public void run()
{
do
{
tvVideoTimer.post(new Runnable()
{
public void run()
{
int time = (duration - mVideoView.getCurrentPosition()) / 1000;
tvVideoTimer.setText(getTimeString(mVideoView.getCurrentPosition()));
}
});
try
{
Thread.sleep(500);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
if (!running) break;
}
while (mVideoView.getCurrentPosition() <= duration);
}
});
thread.start();
}
catch (Exception e)
{
e.printStackTrace();
}
}

How to Play the online streaming radio in Android

I am developing one application where i want to play live stream radio. I have an url using which i will stream the radio and play. I have a play button by clicking which i want to play the radio. For that, i have written some code which is not at all working. Here is my code:
mp = new MediaPlayer();
try {
mp.setOnPreparedListener(this);
Log.d("Testing", "start111");
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
String url="xxxxxx";
mp.setDataSource(url);
mp.prepareAsync();
} catch (IllegalArgumentException e) {
e.printStackTrace();
Log.d("Testing", "Exception ::: 1111 "+e.getMessage());
} catch (IllegalStateException e) {
Log.d("Testing", "Exception ::: 2222 "+e.getMessage());
e.printStackTrace();
} catch (IOException e) {
Log.d("Testing", "IOException ::: 3333 "+e.getMessage());
e.printStackTrace();
}
Can anyone please help me??
You can find good information regarding radio streaming.
Github radio streaming example
and also there is a question in SOF which can also be helpful
Stackoverflow radio streaming example
Hope it will help. thanks
Try this.
public class RadioStream extends Activity {
private final static String stream = "http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio2_mf_p";
Button play;
MediaPlayer mediaPlayer;
boolean started = false;
boolean prepared = false;
/**
* Called when the activity is first created.
*/
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_radio_stream);
play = (Button) findViewById(R.id.play);
play.setEnabled(false);
play.setText("Loading..");
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
play.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (started) {
mediaPlayer.pause();
started = false;
play.setText("Play");
} else {
mediaPlayer.start();
started = true;
play.setText("Pause");
}
}
});
new PlayTask().execute(stream);
}
#Override
protected void onPause() {
super.onPause();
/* if(started)
mediaPlayer.pause();*/
}
#Override
protected void onResume() {
super.onResume();
/*if(started)
mediaPlayer.start();*/
}
#Override
protected void onDestroy() {
super.onDestroy();
// mediaPlayer.release();
}
private class PlayTask extends AsyncTask<String, Void, Boolean> {
#Override
protected Boolean doInBackground(String... strings) {
try {
mediaPlayer.setDataSource(strings[0]);
mediaPlayer.prepare();
prepared = true;
} catch (IOException e) {
e.printStackTrace();
}
return prepared;
}
#Override
protected void onPostExecute(Boolean aBoolean) {
super.onPostExecute(aBoolean);
play.setEnabled(true);
play.setText("Play");
}
}
}
Please do try the code below and call the given method at the on create of your activity or at the onclick listener of your button. Remember to handle the stop and start button the imgV is an imageView for my button.
private MediaPlayer player;
private void startMediaPlayer() {
String url = "http:yoururl.com"; // your URL here
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(url);
} catch (IllegalArgumentException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SecurityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IllegalStateException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(isPlaying){
try {
mediaPlayer.prepareAsync();
progress.setVisibility(View.VISIBLE);
} catch (IllegalStateException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mediaPlayer.start();
}
});
}
mediaPlayer.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
public void onBufferingUpdate(MediaPlayer mp, int percent) {
}
});
}
boolean isPlaying = true;
private void startPlaying() {
isPlaying = true;
mediaPlayer.prepareAsync();
mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mediaPlayer.start();
}
});
imgV.setImageResource(R.drawable.stop);
}
private void stopPlaying() {
if (mediaPlayer.isPlaying()) {
isPlaying = false;
mediaPlayer.stop();
mediaPlayer.release();
initializeMediaPlayer();
}
imgV.setImageResource(R.drawable.play);
}

Android Playing MediaPlayer in SeparateThread

I have a Mp3Link need to play it on my Device in a Separate Thread
I have tried this,But when i execute my code ,I'm not able to play the Music,Could any one look at My Code,What Went Wrong?
Here My Code:
Thread trd = new Thread(new Runnable(){
public void run(){
//code to do the HTTP request
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(mp3Link);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.prepareAsync();
// You can show progress dialog here untill it prepared to play
mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
// Now dismis progress dialog, Media palyer will start playing
Log.d("Mediaplyer>>>>>>>>", "Mediaplyer>>>>>>>>");
mp.start();
}
});
mediaPlayer.setOnErrorListener(new OnErrorListener() {
public boolean onError(MediaPlayer mp, int what, int extra) {
// dissmiss progress bar here. It will come here when
// MediaPlayer
// is not able to play file. You can show error message to user
return false;
}
});
}
});
trd.start();
How about put
mediaPlayer.prepareAsync();
at the end of run() function ?
Thread trd = new Thread(new Runnable(){
public void run(){
//code to do the HTTP request
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(mp3Link);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// mediaPlayer.prepareAsync(); // <== Marked
// You can show progress dialog here untill it prepared to play
mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
// Now dismis progress dialog, Media palyer will start playing
Log.d("Mediaplyer>>>>>>>>", "Mediaplyer>>>>>>>>");
mp.start();
}
});
mediaPlayer.setOnErrorListener(new OnErrorListener() {
public boolean onError(MediaPlayer mp, int what, int extra) {
// dissmiss progress bar here. It will come here when
// MediaPlayer
// is not able to play file. You can show error message to user
return false;
}
});
mediaPlayer.prepareAsync(); // <== Add
}
});
trd.start();
Hope this helps.

Android: Stop sound files playing at once

In the application I am currently writing, a user is able to select an entry from the database and play the contents of that entry: an entry is made up of a number of sound files (without a limit). In my application, I return the URI locations of the sound files of an entry (which have been stored in my database) in a List. The code is as follows:
public void audioPlayer() {
// set up MediaPlayer
MediaPlayer mp = new MediaPlayer();
DatabaseHandler db = new DatabaseHandler(this);
Entry retrieveEntry = new Entry();
retrieveEntry = db.getEntry();
List<String> path = retrieveEntry.getAudioUri();
path.size();
System.out.println("PATH SIZE: " +path.size());
System.out.println("FILEZ: " + path);
Iterator<String> i = path.iterator();
String myAudio;
int count = 0;
while (i.hasNext()) {
System.out.println(count);
myAudio = i.next();
System.out.println("MY AUDIO: " + myAudio);
MediaPlayer player = MediaPlayer.create(this, Uri.parse(myAudio));
player.start();
player.stop();
player = MediaPlayer.create(this, Uri.parse(myAudio));
player.start();
count++;
}
}
My users require that there be user input for playing a file - is there a way to play the first file, then wait for the user to press the button, then play the second file, then wait for the user to press the button, etc.? At the moment, when the play button is pressed, all of the sound files that have been returned get played at the same time, rather than one after the other.
Thanks in advance for any help provided!
You can use this class to play a playlist. This will start one audio, when that audio finishes, it will start playing next audio till the end of the list. If you want to play the playlist in looping i.e start first audio after reaching end, then pass isLooping=true in startPlayingPlaylist(list,looping)
AudioPlayer player = new AudioPlayer();
player.startPlayingPlaylist(list, false);
Class
public class AudioPlayer{
MediaPlayer player = null;
ArrayList<String> playlist = null;
int position = 0;
public AudioPlayer() {
super();
// TODO Auto-generated constructor stub
}
public void startPlayingPlaylist(ArrayList<String> list, boolean looping){
playlist = list;
if(player!=null){
player.release();
}
if(playlist!=null && playlist.size()>0){
player = MediaPlayer.create(LMApplicaton.getInstance(),Uri.parse(playlist.get(position)));
player.setWakeMode(LMApplicaton.getInstance(), PowerManager.PARTIAL_WAKE_LOCK);
player.setLooping(looping);
player.start();
// Set onCompletion listener
player.setOnCompletionListener(new OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mp) {
position = position+1;
if(position<playlist.size()){
try {
player.reset();
player.setDataSource(playlist.get(position));
player.prepareAsync();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else if(player.isLooping()==true){
position = position%playlist.size();
try {
player.reset();
player.setDataSource(playlist.get(position));
player.prepareAsync();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
else if(player.isLooping()==false){
player.release();
player = null;
}
}
});
player.setOnPreparedListener(new OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
player.start();
}
});
}
}
public void pause(){
if(player!=null && player.isPlaying()){
player.pause();
}
}
public void play(){
if(player!=null && player.isPlaying()==false){
player.start();
}
}
public boolean isPlaying(){
return player.isPlaying();
}
public void release(){
if(player!=null){
player.release();
}
}
}
Edit:
The class below receives a list of audios, then plays first Audio. It plays next audio when user calls startNextAudio() You can use any one of these according to your requirements
public class AudioPlayer{
MediaPlayer player = null;
ArrayList playlist = null;
int position = 0;
public AudioPlayer() {
super();
// TODO Auto-generated constructor stub
}
public void startPlayingPlaylist(ArrayList<String> list){
playlist = list;
if(player!=null){
player.release();
}
if(playlist!=null && playlist.size()>0){
player = MediaPlayer.create(LMApplicaton.getInstance(),Uri.parse(playlist.get(position)));
player.setWakeMode(LMApplicaton.getInstance(), PowerManager.PARTIAL_WAKE_LOCK);
player.start();
// Set onCompletion listener
player.setOnPreparedListener(new OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
player.start();
}
});
}
}
public void startNextAudio(){
position = position+1;
if(position<playlist.size()){
try {
player.reset();
player.setDataSource(playlist.get(position));
player.prepareAsync();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else if(player.isLooping()==true){
position = position%playlist.size();
try {
player.reset();
player.setDataSource(playlist.get(position));
player.prepareAsync();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}else{
Log.i("AudioPlayer","Playlist reached at the end");
}
}
public void pause(){
if(player!=null && player.isPlaying()){
player.pause();
}
}
public void play(){
if(player!=null && player.isPlaying()==false){
player.start();
}
}
public boolean isPlaying(){
return player.isPlaying();
}
public void release(){
if(player!=null){
player.release();
}
}
}
One approach would be to implement the MediaPlayer.OnCompletionListener interface. This gives you the MediaPlayer.onCompletion() callback method which you could use like so:
#Override
public void onCompletion(MediaPlayer mp) {
if (i.hasNext) {
// ...hand mp the next file
// ...show the user the 'play next' button
}
}
Note you also will need to call the MediaPlayer.setOnCompletionListener() method in your setup.

Categories

Resources