我已经成功下载并存储了扩展文件。但是当我尝试在里面播放mp3时它会崩溃..
ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(getApplicationContext(),
1, 0);
InputStream fileStream = expansionFile.getInputStream("mysong.mp3");
AssetFileDescriptor asd = expansionFile.getAssetFileDescriptor("mysong.mp3");
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(asd.getFileDescriptor(), asd.getStartOffset(), asd.getLength());
asd.close();
mediaPlayer.prepare();
mediaPlayer.start();
这里logcat说输入流和文件描述符都是空的。任何人都可以帮助我吗?
答案 0 :(得分:2)
最终解决了..文件名应该是完整路径..
AssetFileDescriptor asd = expansionFile.getAssetFileDescriptor("main.1.com.mypackage.app/mysong.mp3");