question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android video playback audio works but no video

See original GitHub issue

Hello,

Revisiting this extension after some inactivity and am currently trying to get mp4 video working on android. I have created a Screen that should be playing video. The problem is that the screen remains blank but the audio plays in the background.

Can you provide any guidance? Ideally I want to be able to render video on android onto a specific texture (in an Actor) so that I can put it in a stage and have other Actors rendered on top of the video.

Below is an excerpt of my Screen class: `public VideoPlayer videoPlayer;

boolean videoLoaded = false;

@Override
public void show() {

    videoPlayer = VideoPlayerCreator.createVideoPlayer();
    videoPlayer.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    videoPlayer.setOnVideoSizeListener(new VideoPlayer.VideoSizeListener() {
        @Override
        public void onVideoSize(float v, float v2) {
            videoLoaded = true;
        }
    });

    try {
        videoPlayer.play(Gdx.files.absolute("/path/to/file.mp4"));

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    Gdx.gl.glEnable(GL20.GL_CULL_FACE);
    Gdx.gl.glCullFace(GL20.GL_BACK);

}

@Override
public void render(float delta) {

    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if(videoLoaded) {
        if (!videoPlayer.render()) { // As soon as the video is finished, we start the file again using the same player.
            try {
                videoLoaded = false;
                videoPlayer.play(Gdx.files.absolute("/path/to/file.mp4"));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }

}`

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
zumbarlalcommented, Sep 11, 2018

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();
                            }

                        }
                    });
0reactions
SimonITcommented, Dec 30, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

8 Ways to Fix Video Sound Not Working on Android
Fix 1: The Volume Settings · Fix 2: Restarting the Device · Fix 3: Wondershare Repairit - Repair No Sound Videos Online/Offline ·...
Read more >
How to Fix 'No sound on Android video' Error
Outdated version of your phone?s operating system (OS ) might result in no sound when playing videos on Android. Update the OS to...
Read more >
7 Methods to Fix Video Not Playing on Android Phone
All you need to do is to close all the running applications on your phone and restart or reboot it. Once your phone...
Read more >
Fix No Sound on Videos When Playing on An Android Phone!
01 Re-Check Basic Settings · First and foremost, hop onto the settings section on your phone, and ensure everything is in place. ·...
Read more >
android video, hear sound but no video - Stack Overflow
public void onCreate ; (Bundle savedInstanceState) · super · this ; SurfaceView v = ; SurfaceHolder holder = ; // Set the transparency...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found