libgdx / gdx-video

A libGDX cross platform video rendering extension
Apache License 2.0
147 stars 50 forks source link

IllegalStateException when trying to replay video #39

Closed lakrsv closed 8 years ago

lakrsv commented 8 years ago

Hi, so I'm trying to replay a video once it completes, but trying to do this throws an IllegalStateException.

Here's the error:

10-31 13:37:27.575 29607-30226/com.brainwavebank E/BufferQueueProducer: [unnamed-29607-0] connect(P): already connected (cur=3 req=3)
10-31 13:37:27.576 2404-2892/? E/MediaPlayerService: setVideoSurfaceTexture failed: -22
10-31 13:37:27.576 2404-2892/? D/NuPlayerDriver: reset(0xe63de8e0)
10-31 13:37:27.576 2404-30997/? D/NuPlayerDriver: notifyResetComplete(0xe63de8e0)
10-31 13:37:27.578 29607-30226/com.brainwavebank E/BufferQueueProducer: [unnamed-29607-0] connect(P): already connected (cur=3 req=3)
10-31 13:37:27.578 2404-16337/? E/MediaPlayerService: setVideoSurfaceTexture failed: -22
10-31 13:37:27.578 2404-16337/? D/NuPlayerDriver: reset(0xe63de8e0)
10-31 13:37:27.581 29607-30226/com.brainwavebank D/ufoEGL: Surface destroy: ANDROID_NATIVE_WINDOW_MAGIC
10-31 13:37:27.673 29607-30226/com.brainwavebank E/AndroidRuntime: FATAL EXCEPTION: GLThread 2525
                                                                   Process: com.brainwavebank, PID: 29607
                                                                   java.lang.IllegalStateException
                                                                       at android.media.MediaPlayer.prepareAsync(Native Method)
                                                                       at com.badlogic.gdx.video.VideoPlayerAndroid.play(VideoPlayerAndroid.java:175)
                                                                       at com.brainwavebank.restingstate.Screens.GameScreen.render(GameScreen.java:232)
                                                                       at com.badlogic.gdx.Game.render(Game.java:46)
                                                                       at com.brainwavebank.restingstate.Screens.GameRenderer.render(GameRenderer.java:42)
                                                                       at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:459)
                                                                       at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
                                                                       at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)

Here is the initial method creating the video:

 private void createVideo()
    {
        try
        {
            videoPlayer = VideoPlayerCreator.createVideoPlayer(videoViewPort);
            videoPlayer.play(Gdx.files.internal("restvideo.mp4"));
        }
        catch(Exception e)
        {
            Gdx.app.log("EXCEPTION", e.toString());
            videoPlayer = null;
        }
    }

Here is the check for looping the video if it is done in the batch.

if(videoPlayer != null)
        {
            videoViewPort.apply();

            if(videoPlayer.isBuffered()) {
                if (!videoPlayer.render()) {
                    try {
                        videoPlayer.play(Gdx.files.internal("restvideo.mp4"));
                    } catch (FileNotFoundException e) {
                        e.printStackTrace();
                    }
                }
            }
        }

Not sure if this is a bug or me doing it wrong, anyone?

RBogie commented 8 years ago

I will look into it this weekend.

lakrsv commented 8 years ago

Regarding this issue;

So it turns out when gdx-video was added to my project that I had a really old version causing all kinds of problems.

I resolved it by downloading the GitHub project and building the jars by myself.

AmitPal100001 commented 2 years ago

Hi @lakrsv ,

How you did fixed this problem? I am getting same problem. Can you please share me solutions for that?

Thanks, Amit

Frosty-J commented 2 years ago

Don't forget to replace 0.0.1 with the current version!

Did you remember to do that, seeing as lakrsv said "I had a really old version"? I'm unsure what the current version is as all I see is "invalid artifact version", so if 1.3.1 doesn't work, try 1.3.2-SNAPSHOT.

Nevermind, apparently there are no releases.

AmitPal100001 commented 2 years ago

Hi,

I want to know what that change you did to fixed this issue. what fixed you did for this in 1.3.2-SNAPSHOT.

I want know what solutions you did for this. can you share me that solutions or hint for this it will be good for me.

I am getting same issue below is the logs that I am getting.

03-17 12:19:27.812 2758 2826 E BufferQueueProducer: [SurfaceView - #0] connect: already connected (cur=2 req=3) 03-17 12:19:27.812 2829 3323 E : 2866:IGraphicBufferProducer.cpp status_t (0) 03-17 12:19:27.812 2829 3323 E Surface : 2866: Suface.cpp connect err (-22) 03-17 12:19:27.812 2829 3323 E Surface : 2866: Suface.cpp connect mConsumerRunningBehind (-22) (3) (2) 03-17 12:19:27.812 2829 3323 E Surface : native cpp: Suface.cpp perform complete (-22) 03-17 12:19:27.812 2829 3323 E SurfaceUtils: Failed to connect to surface 0xe93e5008, err -22 03-17 12:19:27.812 2829 3323 E MediaPlayerService: setVideoSurfaceTexture failed: -22 03-17 12:19:27.813 2829 3323 E Surface : 2866:Surface.cpp ::~Surface() (0) 03-17 12:19:27.814 8657 8657 D AndroidRuntime: Shutting down VM --------- beginning of crash 03-17 12:19:27.815 8657 8657 E AndroidRuntime: FATAL EXCEPTION: main 03-17 12:19:27.815 8657 8657 E AndroidRuntime: Process: jp.co.ricoh.advop.customize, PID: 8657 03-17 12:19:27.815 8657 8657 E AndroidRuntime: java.lang.IllegalStateException 03-17 12:19:27.815 8657 8657 E AndroidRuntime: at android.media.MediaPlayer._prepare(Native Method) 03-17 12:19:27.815 8657 8657 E AndroidRuntime: at android.media.MediaPlayer.prepare(MediaPlayer.java:1274) 03-17 12:19:27.815 8657 8657 E AndroidRuntime: at jp.co.ricoh.advop.customize.view.VideoSurfaceView$1.onPostExecute(VideoSurfaceView.java:155) 03-17 12:19:27.815 8657 8657 E AndroidRuntime: at jp.co.ricoh.advop.customize.view.VideoSurfaceView$1.onPostExecute(VideoSurfaceView.java:106) 03-17 12:19:27.815 8657 8657 E AndroidRuntime: at android.os.AsyncTask.finish(AsyncTask.java:755) 03-17 12:19:27.815 8657 8657 E AndroidRuntime: at android.os.AsyncTask.access$900(AsyncTask.java:192) 03-17 12:19:27.815 8657 8657 E AndroidRuntime: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772) 03-17 12:19:27.815 8657 8657 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107) 03-17 12:19:27.815 8657 8657 E AndroidRuntime: at android.os.Looper.loop(Looper.java:214) 03-17 12:19:27.815 8657 8657 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7356)

Thanks, Amit

Frosty-J commented 2 years ago

Sorry, I haven't experienced this issue. Is this with your own code, or the test?

AmitPal100001 commented 2 years ago

Hi,

This is my own code but I am getting same issue. it will be good if you can provide me some hints to fix this.

I think this issue in BufferQueueProducer in native class but still I am not sure exactly where this issue.

I hope you fixed that if you have any idea about this please share me.

Thanks, Amit