I know there are already a few questions like this on SO, but they relate to extracting the file before playing it.
In the Android docs here it explains that you can play files directly from a .zip file without extracting it.
Tip: If you're packaging media files into a ZIP, you can use media playback calls on the files with offset and length controls (such as MediaPlayer.setDataSource() and SoundPool.load()) without the need to unpack your ZIP. In order for this to work, you must not perform additional compression on the media files when creating the ZIP packages. For example, when using the zip tool, you should use the -n option to specify the file suffixes that should not be compressed:
zip -n .mp4;.ogg main_expansion media_files
I've made an (uncompressed) zip package, but I cannot figure out how to get from a ZipEntry
to a FileDescriptor
, and they don't explain any further. How do I get a FileDescriptor
without unpacking the zip file?
Relative offset of local file header
andCompressed size
to find the start of the data and its length. You should also at least check theCompression method
to be sure the file is uncompressed, and as long as it is not compressed, use the data, otherwise uncompress the data first, then use it. – Happstore
using 7zip, and the .zip file's size is equal to the sum of the unzipped files so I think I've zipped them correctly. Other than that, I have no idea what you're talking about :P – Lundy