AVAudioPlayer 怎样获取当前音频文件的总播放时长
1个回答
展开全部
MediaPlayer md = new MediaPlayer();
try {
LogUtils.log(Environment.getExternalStorageDirectory() +"/123.mp3");
md.setDataSource(Environment.getExternalStorageDirectory() +"/123.mp3");
md.prepare();
LogUtils.log("size " + md.getDuration());
} catch (Exception e) {
e.printStackTrace();
}
MediaPlayer 初始化 -> setDataSource->prepare-> 就可以获取到了getDuration() 单位是ms
try {
LogUtils.log(Environment.getExternalStorageDirectory() +"/123.mp3");
md.setDataSource(Environment.getExternalStorageDirectory() +"/123.mp3");
md.prepare();
LogUtils.log("size " + md.getDuration());
} catch (Exception e) {
e.printStackTrace();
}
MediaPlayer 初始化 -> setDataSource->prepare-> 就可以获取到了getDuration() 单位是ms
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询