IllegalStateException异常从扩充档案VideoView的MediaPlayer的。prepareAsync() [英] IllegalStateException in VideoView's MediaPlayer.prepareAsync() from Expansion File

查看:1352
本文介绍了IllegalStateException异常从扩充档案VideoView的MediaPlayer的。prepareAsync()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个扩展文件(ZIP)充满了,我想用VideoView播放MP4视频。当我VideoView的openVideo调用videoView.setVideoURI()它抛出和IllegalStateException异常(prepareAsync状态1的称呼)()。我检索URI从扩展APEZProvider类视频。

I have an Expansion File (zip) full of mp4 videos that I'd like to play with the VideoView. When calling videoView.setVideoURI() it throws and IllegalStateException (prepareAsync called in state 1) in my VideoView's openVideo(). I retrieve the URI to the video from an extended APEZProvider class.

该扩展文件得到挤得像下方,重命名为main.3.com.my.application.obb

The expansion file got packed like below and renamed to "main.3.com.my.application.obb"

zip -r -0 [desiredZipFileName.obb] [folderWithVideos]

VideoView:

VideoView:

Uri uri = ExpansionAPEZProvider.buildUri("vid_intro.mp4");
videoView = (VideoView) activity.findViewById(R.id.videoview);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();

自定义APEZ Provider类。

The Custom APEZ Provider class.

public class ExpansionAPEZProvider extends APEZProvider {

private static final String AUTHORITY = AndroidApplication.getApplication().getPackageName() + ".provider." + ExpansionAPEZProvider.class.getSimpleName();

    @Override
    public String getAuthority() {
        return AUTHORITY;
    }

    public static Uri buildUri(String path) {
        StringBuilder contentPath = new StringBuilder("content://");
        contentPath.append(AUTHORITY);
        contentPath.append(File.separator);
        contentPath.append(path);

        String newPath = contentPath.toString();

        return Uri.parse(newPath);
    }
}

buildUri()返回一个URI这样

buildUri() returns an URI like this

内容://com.my.application.provider.ExpansionAPEZProvider/vid_intro.mp4

"content://com.my.application.provider.ExpansionAPEZProvider/vid_intro.mp4"

提供的清单:

<provider android:name=".ExpansionAPEZProvider"
        android:authorities="com.my.application.provider.ExpansionAPEZProvider"
        android:exported="false"
        android:multiprocess="true">

        <meta-data
            android:name="mainVersion"
            android:value="3"/>
    </provider>

堆栈跟踪

    V/WindowManager(  749): Adding window Window{683bb62 u0 SurfaceView} at 13 of 21 (before Window{22e3dff1 u0 com.my.application/com.my.application.activity.StartActivity})
    I/MediaFocusControl(  749):  AudioFocus  requestAudioFocus() from android.media.AudioManager@2335d19 req=1flags=0x0
    E/MediaPlayer(15769): prepareAsync called in state 1
    D/AndroidRuntime(15769): Shutting down VM
    E/AndroidRuntime(15769): FATAL EXCEPTION: main
    E/AndroidRuntime(15769): Process: com.my.application, PID: 15769
    E/AndroidRuntime(15769): java.lang.IllegalStateException
    E/AndroidRuntime(15769):    at android.media.MediaPlayer.prepareAsync(Native Method)
    E/AndroidRuntime(15769):    at android.widget.VideoView.openVideo(VideoView.java:356)
    E/AndroidRuntime(15769):    at android.widget.VideoView.access$2100(VideoView.java:72)
    E/AndroidRuntime(15769):    at android.widget.VideoView$7.surfaceCreated(VideoView.java:628)
    E/AndroidRuntime(15769):    at android.view.SurfaceView.updateWindow(SurfaceView.java:580)
    E/AndroidRuntime(15769):    at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:176)
    E/AndroidRuntime(15769):    at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
    E/AndroidRuntime(15769):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1970)
    E/AndroidRuntime(15769):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
    E/AndroidRuntime(15769):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
    E/AndroidRuntime(15769):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
    E/AndroidRuntime(15769):    at android.view.Choreographer.doCallbacks(Choreographer.java:580)
    E/AndroidRuntime(15769):    at android.view.Choreographer.doFrame(Choreographer.java:550)
    E/AndroidRuntime(15769):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
    E/AndroidRuntime(15769):    at android.os.Handler.handleCallback(Handler.java:739)
    E/AndroidRuntime(15769):    at android.os.Handler.dispatchMessage(Handler.java:95)
    E/AndroidRuntime(15769):    at android.os.Looper.loop(Looper.java:135)
    E/AndroidRuntime(15769):    at android.app.ActivityThread.main(ActivityThread.java:5254)
    E/AndroidRuntime(15769):    at java.lang.reflect.Method.invoke(Native Method)
    E/AndroidRuntime(15769):    at java.lang.reflect.Method.invoke(Method.java:372)
    E/AndroidRuntime(15769):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    E/AndroidRuntime(15769):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
    W/ActivityManager(  749):   Force finishing activity 1 com.my.application/.activity.StartActivity
    W/DropBoxManagerService(  749): Dropping: data_app_crash (1630 > 0 bytes)
    I/WindowManager(  749): Screenshot max retries 4 of Token{2d07c562 ActivityRecord{3b01f344 u0 com.my.application/.activity.StartActivity t8900 f}} appWin=Window{683bb62 u0 SurfaceView} drawState=3

感谢您的帮助。

推荐答案

我固定它。这个zip / OBB文件必须被打破。我又通过终端包装它作为在上面的描述后,现在它的作品。我花了年龄找到问题所在。
而不是IllegalStateException异常出现FileNotFoundException或IOException异常将有更多的帮助我找到问题。

I fixed it. The zip/obb file must have been broken. I packed it again via terminal as described in the post above and now it works. Took me ages to find the problem. A FileNotFoundException or IOException instead of the IllegalStateException would have been more helpful to me to locate the problem.

这篇关于IllegalStateException异常从扩充档案VideoView的MediaPlayer的。prepareAsync()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆