Comments (18)
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Actually, I just see the example enabling culling. Could you try to see whether that might be hiding your texture?
from gdx-video.
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.
Yes. You could either disable culling, or try Gdx.gl.glCullFace(GL20.GL_FRONT_AND_BACK)
from gdx-video.
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.
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.
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.
Could you try if the issue persists with the newest snapshot?
from gdx-video.
Related Issues (20)
- ffmpeg codec arguments HOT 2
- Black screen while play on Android hardware device HOT 2
- Unable to play video from cross origin GWT Libgdx HOT 1
- IOS platform support and video file format extension HOT 1
- setlooping(true) does not work on desktop. HOT 1
- MP4, Could not find a suitable audio decoder! even with --enable-decoder=h264 or --enable-libx264 HOT 9
- Error on 1920x1080 videos in mp4, Could not find codec parameters for stream 0 HOT 2
- Rewind / forward is supported? HOT 2
- update to current libgdx and include desktop loopback support HOT 1
- Video does not play when asset filter is used
- Videos cannot be loaded without playing HOT 2
- error with music in newst libgdx version HOT 2
- Is it possible to run the Desktop sample too? HOT 6
- Could not open WebM file after latest commits HOT 3
- video is flickering HOT 1
- AV1 Decoding does not work on Desktop HOT 3
- `isPlaying()` behaviour across backends
- Does not work on Java 8 HOT 3
- Not in the Sonatype Repository at all: Add the version for the Dependency in the Readme HOT 4
- Why is mp4 not a supported format for Desktop HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdx-video.