使用 MediaPlayer过程中 的疑惑
MediaPlayer mp=new MediaPlayer();
MediaPlayer mp1=new MediaPlayer();
AssetFileDescriptor afd = null;
AssetFileDescriptor afd1 = null;
afd = getAssets().openFd("m1.mp3");
afd1 = getAssets().openFd("m2.mp3");
mp.setDataSource(afd.getFileDescriptor());
mp1.setDataSource(afd1.getFileDescriptor());
mp.prepare();
mp.start();
为什么我的m1音乐播放完了还会播放m2音乐?很奇怪,请大家帮我看看到底怎么回事 mediaplayer 音乐
[解决办法]
把文件放在raw里试试~~
[解决办法]
你的mp1 根本没有运行
afd.getFileDescriptor()
返回的是这个类型 AssetFileDescriptor
SDK中的解释
File descriptor of an entry in the AssetManager. This provides your own opened FileDescriptor that can be used to read the data, as well as the offset and length of that entry's data in the file
setDataSource(FileDescriptor)
你加载了一个过滤器 所以 你mp setDataSource 的时候 将你的 m1 m2 都设置上去了 所以两个音乐都播放了。这个是我对我SDK 的分析理解 如果你需要测试 你可以将两个音乐放到 SD卡上 在写一个 文件过滤器设置里面 你看是否 会播放两个音乐。
[解决办法]
http://blog.csdn.net/yexing/article/details/6196437