I'm developing a game using cocos2d-x and I want to play video in it. The activity has one OpenGL view and I also put additional VideoView on top of it and set visibility to INVISIBLE.
When I need to play video, I just hide OpenGL view and enable my VideoView. After that I create MediaPlayer, call setDisplay with holder of that VideoView, etc. and eventually video plays well. When video finishes, I switch visibilities back again - opengl to VISIBLE and videoview to INVISIBLE.
However, the problem is that when I try to play video second time, it just doesn't show up, however, sound from the video is being played.
Is there any catch with visibilities?
I just modified the ApiDemo to see whether it works. I have blog the full code here : post without using separate media player for video view we can set the video and play
mVideoView.setVideoURI(data.getData());
mVideoView.setVisibility(View.VISIBLE);
mVideoView.start();
//I could add touch listener in onCreate
mGLSurfaceView.setOnTouchListener(...);
//touch event will go all the way down to GLSurfaceView
//Here i could chnage the video view position
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
mVideoView.setTranslationX(motionEvent.getX());
mVideoView.setTranslationY(motionEvent.getY());
return true;
}
You will need a surfaceview to play video at using android MediaPlayer class.
To play video above GLSurfaceView, create an android Custom Dialog which contains a surfaceView and play video on that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With