10

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 ?

hacker
  • 8,919
  • 12
  • 62
  • 108
  • does this question solve your issue http://stackoverflow.com/questions/10051213/accessing-apk-expansion-file-with-uri-with-google-zip-expansion-library-causes ? – Nimish Choudhary Jan 15 '13 at 09:44

1 Answers1

2

Finaly it solved.. The file name should be with the full path..

AssetFileDescriptor asd = expansionFile.getAssetFileDescriptor("main.1.com.mypackage.app/mysong.mp3");
hacker
  • 8,919
  • 12
  • 62
  • 108