getFileDescriptor同时读取MP3文件从扩展文件返回null [英] getFileDescriptor returns null while reading mp3 files from the expansion files
本文介绍了getFileDescriptor同时读取MP3文件从扩展文件返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经下载并存储在扩展文件successfully.But崩溃,当我尝试里面播放MP3 ..
I have downloaded and stored the expansion files successfully.But it crashes when i try to play the mp3 inside..
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同时InputStream和文件描述符是null..Can谁能帮助我?
Here the logcat says both the inputstream and the file descriptor are null..Can anyone help me ?
推荐答案
Finaly它解决。该文件的名称应与完整路径。
Finaly it solved.. The file name should be with the full path..
AssetFileDescriptor asd = expansionFile.getAssetFileDescriptor("main.1.com.mypackage.app/mysong.mp3");
这篇关于getFileDescriptor同时读取MP3文件从扩展文件返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文