10

On the SD-card I have a zip file containing one video file (.mp4). I need to play that video file via a VideoView without extracting the zip.

So far I have tried :

ZipFile zipFile = new ZipFile(new File("/sdcard/checking.zip"));
ZipEntry zipEntry = zipFile.getEntry("checking.mp4");
InputStream inStream  = zipFile.getInputStream(zipEntry);

But I don't find any API that plays video from InputStream. zipEntry.getSize() does return the value.

I tried videoView.setVideoURI(Uri.parse("//sdcard/checking.zip!/checking.mp4")); from HERE

But it shows "Can't play video". So how do I do that (mentioned in the title) on android.

Community
  • 1
  • 1
IronBlossom
  • 3,898
  • 3
  • 35
  • 42
  • Protocol goes before the // (http:// etc) so try jar:file://sdcard/checking.zip!/checking.mp4 – FunkTheMonk Feb 18 '13 at 11:55
  • still not working!! gives MediaPlayer:path is null on LogCat – IronBlossom Feb 18 '13 at 12:23
  • Is the sdcard directly mapped to //sdcard/ (it could be //storage/sdcard0/ or something) - use http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory() rather than hardcoding it – FunkTheMonk Feb 18 '13 at 15:17
  • I tried videoView.setVideoURI(Uri.parse("jar:file://"+Environment.getExternalStorageDirectory()+"/checking.zip!/checking.mp4")); And videoView.setVideoPath("jar:file://"+Environment.getExternalStorageDirectory()+"/checking.zip!/checking.mp4"); both cases it returns uri is:jar:file:///mnt/sdcard/checking.zip!/checking.mp4 MediaPlayer(3514): path is null – IronBlossom Feb 19 '13 at 05:26
  • 1
    Do you have the read external permission, I believe some devices may already be enforcing it – FunkTheMonk Feb 19 '13 at 09:25
  • 1
    still returns: uri is:jar:file:///mnt/sdcard/checking.zip!/checking.mp4 MediaPlayer(3514): path is null – IronBlossom Feb 19 '13 at 09:33
  • Are there any other error codes in logcat? – FunkTheMonk Feb 19 '13 at 09:44
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/24751/discussion-between-ironblossom-and-funkthemonk) – IronBlossom Feb 19 '13 at 09:44
  • Why do you even want to do this? It doesn't make much sense... – Warpzit Feb 20 '13 at 09:01
  • @Warpzit right. dunno....client wants it that way – IronBlossom Feb 20 '13 at 10:47
  • And client also want you to not pack it out? Sounds like the Client is too technical and you are too compliant. – Warpzit Feb 20 '13 at 11:02
  • @Warpzit "And client also want you to not pack it out?" yes. I didn't complain someone. Im stuck here about 2days and didn't find any solution yet. they dont want to stream and dont even want to expose that to public.(that's another story) I saw this on http://stackoverflow.com/questions/8664247/how-to-read-a-file-directly-from-a-zip-file-without-extracting-it-in-android i thought i should work for video as well – IronBlossom Feb 20 '13 at 12:33
  • What about saving to internal memory (not accessible for the user) and then play it from there? Also here is some possible suggestions to make it work from stream: http://stackoverflow.com/questions/5272664/create-mediaplayer-with-inputstream-in-android – Warpzit Feb 20 '13 at 12:36
  • rooted user can access that....besides the video will be about 700mb(2hour) .. as you guess he's "TOO TECHNICAL" – IronBlossom Feb 20 '13 at 12:55
  • Is your ZIP file compressed. If so, you can't play media directly from the ZIP file. Make sure the ZIP file is uncompressed. See this link briefly mentioning this: http://developer.android.com/google/play/expansion-files.html#ZipLib – Streets Of Boston Feb 26 '13 at 17:27
  • Check this example: [stackoverflow](http://stackoverflow.com/questions/9623350/where-is-the-samplezipfileprovider-class) – elirigobeli Nov 20 '13 at 14:58

2 Answers2

0

With the VideoView or MediaPlayer you can't do that

HocineHamdi
  • 191
  • 6
0

To be honest I am having the same problem. But in the Expansion Files documentation it says you need to zip the file in a particular way in order to read straight from the zip folder. You shouldn't apply any compression to the media inside.

Hope this helps...

I just don't really know how to zip like that.

JoshySav
  • 81
  • 1
  • 8