Giter Club home page Giter Club logo

Comments (18)

zumbarlal avatar zumbarlal commented on May 22, 2024 1

For android video play using libgdx
You need to use below in screen class

@Override
    public void render(float delta) {
         batch.begin();
         if (videoPlayerAndroid!=null && videoPlayerAndroid.isBuffered()) {
               videoPlayerAndroid.render();
        }
}

and you can play video from activity

Gdx.app.postRunnable(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                VideoPlayerAndroid videoPlayerAndroid = new VideoPlayerAndroid(sensesMainBoard.getmDrawScreen().getStage().getViewport());
//                        videoPlayerAndroid.resize(200,100);
                                FileHandle fileHandle = new FileHandle(getPath(videoUri));
                                videoPlayerAndroid.play(fileHandle);
                                screen.addVideo(videoPlayerAndroid);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }

                        }
                    });

from gdx-video.

MaximilianWang avatar MaximilianWang commented on May 22, 2024

After further investigation it seems that this problem is device specific. On some devices it can even play two concurrent videos with no problems but on some it is just blank screen with audio in the back ground.

from gdx-video.

RBogie avatar RBogie commented on May 22, 2024

In that case it can only be one of two issues: Either the device does not support the video codec used, or the device does not support the SurfaceTexture that is used for efficient video -> texture conversion

from gdx-video.

MaximilianWang avatar MaximilianWang commented on May 22, 2024

I see. So if I replace SurfaceTexture then that may do the trick?

Also I am currently trying to play videos consecutively by invoking videoPlayer.play(new file) when the current one is completed. The problem is that it causes the entire app to freeze for a little bit and then go back to normal as the next video comes in. How would you suggest I go about doing this in a way that does not freeze the UI thread? Would I be able to create another VideoPlayer object and load the next video (but not invoke mediaPlayer.start()) in a separate thread and then pass the new object to the Screen object?

from gdx-video.

RBogie avatar RBogie commented on May 22, 2024

Replacing SurfaceTexture is hardly possible. However, codecs are the most likely issue anyway, so I would first look into this (Try to see whether the android media player can play the file. If it does, the device does not support SurfaceTexture. If it does not play the video, it is a codec issue).

Gdx-video does not prevent you in making multiple players. However, the android mediaplayer that is used in the background does have some requirements on threading. I would check the android documentation to see what it states exactly about the threading (It's a long time since I implemented the code, so I can't remember the threading details on android anymore).

from gdx-video.

dbeef avatar dbeef commented on May 22, 2024

or the device does not support the SurfaceTexture that is used for efficient video -> texture conversion

Pardon, but how exactly may I handle this particular situation?

from gdx-video.

RBogie avatar RBogie commented on May 22, 2024

If that is the case, there is no easy/clear fix. The problem is that the only alternative would be using the desktop approach with ffmpeg. However, on a mobile phone the performance would instantly become an issue.

Have you tried whether the file works in different players?

from gdx-video.

dbeef avatar dbeef commented on May 22, 2024

Thx for a quick answer!

Any Android update would not fix it? I'm 4.2.2.

If no, would you recommend interfacing native android MediaPlayer as necessity?

from gdx-video.

RBogie avatar RBogie commented on May 22, 2024

Android updates might fix it, given the fact that the video also doesn't work in a different player (try to play it in your device's gallery.

I would say interfacing with the native android MediaPlayer is a necessity, because, unless the video is very small and low quality, the phone's cpu would struggle with decoding, and the bandwidth for texture transfers would be troublesome too. By using the native MediaPlayer, you can use the GPU for decoding, and don't have the extra step of getting the raw image to the GPU.

from gdx-video.

dbeef avatar dbeef commented on May 22, 2024

I played it in a built-in android gallery, no errors, no crashes. When playing via gdx-video, there's only audio and a black screen. Tried also on an emulator of Nexus 5, same.

Pity, I'll try with the MediaPlayer, but thanks anyway, really good work with the project.

from gdx-video.

RBogie avatar RBogie commented on May 22, 2024

The emulator is known to not work with gdx-video on certain SDK versions.

However, the fact that the video is playing in the gallery just fine, makes me believe that it is indeed the SurfaceTexture that is not supported. It might be fixed by an android update, however I think it is unlikely.

Honestly, I don't know how to fix this. You might try a different codec for the video, but then again, if it is the SurfaceTexture, it probably won't make a difference.

from gdx-video.

RBogie avatar RBogie commented on May 22, 2024

Actually, I just see the example enabling culling. Could you try to see whether that might be hiding your texture?

from gdx-video.

dbeef avatar dbeef commented on May 22, 2024

https://developer.android.com/guide/topics/graphics/opengl.html

Do you mean this one?

// enable face culling feature
gl.glEnable(GL10.GL_CULL_FACE);

from gdx-video.

RBogie avatar RBogie commented on May 22, 2024

Yes. You could either disable culling, or try Gdx.gl.glCullFace(GL20.GL_FRONT_AND_BACK)

from gdx-video.

dbeef avatar dbeef commented on May 22, 2024

Tried both, separatly, and after that, combined one after another, didn't work.
Also, my log is writing this every render call:

06-18 12:01:09.142 16524-16579/ E/emuglGLESv2_enc: glDrawElements: no data bound to the command - ignoring
06-18 12:01:09.208 16524-16579/ W/GLConsumer: [SurfaceTexture-100-16524-1] bindTextureImage: clearing GL error: 0x502

from gdx-video.

RBogie avatar RBogie commented on May 22, 2024

Hmmz, don't know what's wrong because the glDrawElements should have data bound.

I will look into this further when I have some time (won't be before at least thursday)

from gdx-video.

dbeef avatar dbeef commented on May 22, 2024

For more details, video works perfectly on desktop project, on android one I tried .3gp, .webm and .mp4, every one of them plays audio but no video.

Thanks for help

from gdx-video.

SimonIT avatar SimonIT commented on May 22, 2024

Could you try if the issue persists with the newest snapshot?

from gdx-video.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.