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();
Here the logcat says both the inputstream and the file descriptor are null..Can anyone help me ?
Finaly it solved.. The file name should be with the full path..
AssetFileDescriptor asd = expansionFile.getAssetFileDescriptor("main.1.com.mypackage.app/mysong.mp3");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With