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音乐

解决方案 »

  1.   

    你的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卡上 在写一个 文件过滤器设置里面 你看是否 会播放两个音乐。
      

  2.   

    http://blog.csdn.net/yexing/article/details/6196437
      

  3.   

    很感谢各位,放到raw是没有了,原因可能就是en332401890 说的