Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 扩展文件中VideoView MediaPlayer.prepareAsync()的非法状态异常_Java_Android_Apk Expansion Files - Fatal编程技术网

Java 扩展文件中VideoView MediaPlayer.prepareAsync()的非法状态异常

Java 扩展文件中VideoView MediaPlayer.prepareAsync()的非法状态异常,java,android,apk-expansion-files,Java,Android,Apk Expansion Files,我试图从我的应用程序的obb扩展中的zip加载mp4文件。我正在使用扩展的APEZProvider获取视频文件的URI。然而;当我设置URI后,应用程序崩溃,出现IllegalStateException 带VideoView的活动: public class LaunchScreen extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(save

我试图从我的应用程序的obb扩展中的zip加载mp4文件。我正在使用扩展的APEZProvider获取视频文件的URI。然而;当我设置URI后,应用程序崩溃,出现IllegalStateException

带VideoView的活动:

public class LaunchScreen extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_launch_screen);
    TextView lets_explore = (TextView) findViewById(R.id.lets_explore);
    TextView explore = (TextView) findViewById(R.id.explore);
    VideoView video = (VideoView) findViewById(R.id.launch_video);
    ImageButton up = (ImageButton) findViewById(R.id.up_arrow);
    Typeface montserrat = Typeface.createFromAsset(getAssets(), "fonts/Montserrat-Bold.ttf");
    Typeface montserratR = Typeface.createFromAsset(getAssets(), "fonts/Montserrat-Regular.ttf");
    lets_explore.setTypeface(montserratR);
    explore.setTypeface(montserrat);
    video.setVideoURI(ZipContentProvider.buildUri("video.mp4"));
    up.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(LaunchScreen.this, MainActivity.class);
            startActivity(i);
        }
    });
}
}
自定义ApezProvider:

public class ZipContentProvider extends APEZProvider {
private static final String AUTHORITY = "com.example.provider.ZipContentProvider";

public static Uri buildUri(String pathIntoApk) {
    StringBuilder contentPath = new StringBuilder("content://");

    contentPath.append(AUTHORITY);
    contentPath.append(File.separator);
    contentPath.append(pathIntoApk);

    return Uri.parse(contentPath.toString());
}

@Override
public String getAuthority() {
    return AUTHORITY;
}
}
清单中的提供者:

<provider android:authorities="net.multieducator.telaviv.provider.ZipContentProvider" android:name=".ZipContentProvider"></provider>

任何帮助都将不胜感激。:)

问题最有可能出现在apk扩展文件中,视频必须存储在未压缩的存档中,否则MediaPlayer无法解码

您为Windows创建未压缩文件的方式->如果使用Winrar或任何其他存档程序,可能存在压缩方法存储,请使用该方法

在Linux或OS X上打开终端并键入


zip-r-0[desiredZipFileName.obb][要添加的文件夹/文件]

问题最有可能出现在apk扩展文件中,视频必须存储在未压缩的存档中,否则MediaPlayer无法解码

您为Windows创建未压缩文件的方式->如果使用Winrar或任何其他存档程序,可能存在压缩方法存储,请使用该方法

在Linux或OS X上打开终端并键入


zip-r-0[desiredZipFileName.obb][folder/file you want add]

我通过在Play Store中使用Alpha测试上传解决了这个问题,但后来我使用了你的方法,所以我会接受你的答案。我通过在Play Store中使用Alpha测试上传解决了这个问题,但我后来使用了你的方法,所以我会接受你的答案
08-14 01:01:30.953: W/asset(14263): AssetManager-->addDefaultAssets CIP path not exsit!
08-14 01:01:32.050: E/MediaPlayer(14263): setDataSource: Null fd! uri=content://net.multieducator.telaviv.provider.ZipContentProvider/video.mp4
08-14 01:01:32.050: E/MediaPlayer(14263): prepareAsync called in state 1
08-14 01:01:32.058: W/dalvikvm(14263): threadid=1: thread exiting with uncaught exception (group=0x40d3a9a8)
08-14 01:01:32.100: E/AndroidRuntime(14263): FATAL EXCEPTION: main
08-14 01:01:32.100: E/AndroidRuntime(14263): java.lang.IllegalStateException
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.media.MediaPlayer.prepareAsync(Native Method)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.widget.VideoView.openVideo(VideoView.java:323)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.widget.VideoView$6.surfaceCreated(VideoView.java:614)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.SurfaceView.updateWindow(SurfaceView.java:617)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.SurfaceView.access$000(SurfaceView.java:88)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:183)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:680)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2123)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1139)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4872)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.Choreographer.doCallbacks(Choreographer.java:579)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.Choreographer.doFrame(Choreographer.java:548)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.os.Handler.handleCallback(Handler.java:800)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.os.Handler.dispatchMessage(Handler.java:100)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.os.Looper.loop(Looper.java:194)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at android.app.ActivityThread.main(ActivityThread.java:5431)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at java.lang.reflect.Method.invokeNative(Native Method)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at java.lang.reflect.Method.invoke(Method.java:525)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-14 01:01:32.100: E/AndroidRuntime(14263):    at dalvik.system.NativeStart.main(Native Method)