2020-11-09 14:39:51.991 10376-10925/com.rhkj.zhihuixue W/MediaPlayer: Couldn't open /storage/emulated/0/Android/data/com.rhkj.zhihuixue/files/Download/aikelun/2-1-1-2-53.mp3
java.io.FileNotFoundException: No content provider: /storage/emulated/0/Android/data/com.rhkj.zhihuixue/files/Download/aikelun/2-1-1-2-53.mp3
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1688)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1518)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1435)
at android.media.MediaPlayer.attemptDataSource(MediaPlayer.java:1159)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1117)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1020)
at android.media.MediaPlayer.create(MediaPlayer.java:927)
at android.media.MediaPlayer.create(MediaPlayer.java:904)
at android.media.MediaPlayer.create(MediaPlayer.java:883)
at com.rhkj.zhihuixue.putong.MainActivityPm92$2.run(MainActivityPm92.java:125)
这个问题好像只出现在小米手机上 有些是因为把网络地址放在了Uri.parse(
"http://xxx.mp3"
)
所以造成这个问题
我用的小米9手机 解析的是本地地址出错了
所以统一改成了:
这个颜色的代码
MediaPlayer mMediaPlayer = new MediaPlayer();
try {
mMediaPlayer.setDataSource(App.getFilesDir+"/"+split[split.length-1]);
}catch (IOException e){
e.printStackTrace();
mMediaPlayer.prepareAsync();
mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.start();
mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
if (mp != null) {
try {
mp.stop();
} catch (Exception e) {
e.printStackTrace();
mp = null;
mp = new MediaPlayer();
mp.stop();
mp.reset();
mp.release();
mp = null;
//题目音播放完毕
//准备A说的话 并播放声音
// if (null!=bean&&bean.getAnswers()!=null&&bean.getAnswers().size()>0)
// playA();
mMediaPlayer.start();