I am trying to directly load an .mp4-File from the expansion file using the APK Expansion Zip Library as suggested here: http://developer.android.com/google/play/expansion-files.html I also included the suggestions made here: Where is the SampleZipfileProvider class?
My Additions to the manifest:
<provider
android:authorities="com.package.app.provider.ZipFileContentProvider"
android:name=".ZipFileContentProvider">
</provider>
My ZipFileContentProvider Class:
package com.package.app;
import com.android.vending.expansion.zipfile.APEZProvider;
public class ZipFileContentProvider extends APEZProvider {
@Override
public String getAuthority() {
return "com.package.app.provider.ZipFileContentProvider";
}
}
My Code:
VideoView vid = (VideoView)findViewById(R.id.videoView1);
String filename = "Main";
final String AUTHORITY = "com.package.app.provider.ZipFileContentProvider";
final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
vid.setVideoURI(Uri.parse(CONTENT_URI + "/" + filename + ".mp4"));
Executing this results in the following log, it crashes the app on prepareAsync called in state 1:
05-20 13:30:31.791: V/MediaPlayer-JNI(23535): native_setup
05-20 13:30:31.791: V/MediaPlayer(23535): constructor
05-20 13:30:31.796: V/MediaPlayer(23535): setListener
05-20 13:30:31.796: I/MediaPlayer(23535): path is null
05-20 13:30:31.811: V/MediaPlayer(23535): setVideoSurfaceTexture
05-20 13:30:31.811: V/MediaPlayer-JNI(23535): setAudioStreamType: 3
05-20 13:30:31.811: V/MediaPlayer(23535): MediaPlayer::setAudioStreamType
05-20 13:30:31.811: V/MediaPlayer(23535): setVideoSurfaceTexture
05-20 13:30:31.811: V/MediaPlayer(23535): prepareAsync
05-20 13:30:31.811: E/MediaPlayer(23535): prepareAsync called in state 1
05-20 13:30:31.811: D/AndroidRuntime(23535): Shutting down VM
05-20 13:30:31.811: W/dalvikvm(23535): threadid=1: thread exiting with uncaught exception (group=0x41d322a0)
05-20 13:30:31.816: E/AndroidRuntime(23535): FATAL EXCEPTION: main
05-20 13:30:31.816: E/AndroidRuntime(23535): java.lang.IllegalStateException
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.media.MediaPlayer.prepareAsync(Native Method)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.widget.VideoView.openVideo(VideoView.java:239)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.widget.VideoView.access$2000(VideoView.java:51)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.widget.VideoView$6.surfaceCreated(VideoView.java:478)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.SurfaceView.updateWindow(SurfaceView.java:609)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.SurfaceView.access$000(SurfaceView.java:86)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:178)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:703)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1956)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1120)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4604)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.Choreographer.doFrame(Choreographer.java:525)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.os.Handler.handleCallback(Handler.java:615)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.os.Handler.dispatchMessage(Handler.java:92)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.os.Looper.loop(Looper.java:137)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.app.ActivityThread.main(ActivityThread.java:4921)
05-20 13:30:31.816: E/AndroidRuntime(23535): at java.lang.reflect.Method.invokeNative(Native Method)
05-20 13:30:31.816: E/AndroidRuntime(23535): at java.lang.reflect.Method.invoke(Method.java:511)
05-20 13:30:31.816: E/AndroidRuntime(23535): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-20 13:30:31.816: E/AndroidRuntime(23535): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-20 13:30:31.816: E/AndroidRuntime(23535): at dalvik.system.NativeStart.main(Native Method)
I can't find the cause for this, any ideas?
Found the issue:
The obb-file I used was compressed, which causes this error. Under OSX I found no proper way of creating an uncompressed file, WinRAR under Windows did the job tho :)