Android: Unknown MediaPlayer Warning

I'm trying to get the duration of the media file using mediaplayer and all works fine but I'm getting a warning in he DDMS as below.

10-21 17:30:35.109: W/MediaPlayer(7564): mediaplayer went away with unhandled events

My code goes as below

//mediaPlayer object initiated to get the duration
MediaPlayer mediaPlayer;
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

try {
mediaPlayer.setDataSource(AudioListActivity.this, Uri.parse((db_results.get(position)).toString()));
mediaPlayer.prepare();
mediaPlayer.stop();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
        e.printStackTrace();
} catch (IllegalStateException e) {

e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//getting duration
int durationTime = 0;
@SuppressWarnings("unused")
TextView duration = (TextView) row.findViewById(R.id.textViewDuration);
durationTime = mediaPlayer.getDuration();
mediaPlayer.release();

Can someone help me out. Thanks in advance.

Answers


It is better to ignore this warning.

1)comment the line of code MediaPlayer.release(); and notice the logcat;

2)You may need to reset the Mediaplayer object before releasing the mp. mp.reset() after that test it. Because some time this will cause other error like "illegal state exception"

3)If it is concern to you, do the reset it in try/catch and handle the exception.


add: mediaPlayer.reset(); before mediaPlayer.release();


Need Your Help

Linux script using tsql

sql sql-server database tsql

I made a script to connect to my sql server. when I copy my script into my terminal it works fine.

Are there Python ORMs out there that support multiple independent databases concurrently in use?

python orm

I'm writing an application in Python where I wish to use sqlite as the backing store for documents edited by the app, with documents generally living in memory, but being saved to disk-based databa...