我试图利用媒体演员获得媒体档案的持续时间,而且所有媒体工作都受到罚款,但我却向他的DDMS发出警告如下。
10-21 17:30:35.109: W/MediaPlayer(7564): mediaplayer went away with unhandled events
我的法典如下:
//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();
一个人能够帮助我。 提前感谢。