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音乐
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音乐
解决方案 »
- 100分求助,android.R.drawable.splash 找不到
- 接收不到PC过过来的广播,跟路由设置有关吗?
- Android开发环境还要装jdk呢?
- android SurfaceView 全屏播放问题
- android listview 分隔线 显示不全 ---- 求正确解决方法
- 有没有用户行为分析平台介绍
- 我用的ADT试了一个HElloword程序,虚拟机调试黑屏,真机正常
- Unable to instantiate activity ComponentInfo
- 初学者提问 -- 如下代码向构造函数传参数的地方哪里写错了?
- 个推的一个小问题
- Android移动设备和Web网页同时访问服务器时,中间层用什么开发合适?希望给予方向性指点。
- http://www.google.com/loc/json停用了,有什么好的替代方法?
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卡上 在写一个 文件过滤器设置里面 你看是否 会播放两个音乐。