Play video on top of OpenGL in android

I am developing a game using cocos2d-x and I want to play it. Activity has one OpenGL view, and I also added a VideoView above it and set the visibility to INVIVIBLE.

When I need to play a video, I just hide the OpenGL view and turn on my VideoView. After that I create a MediaPlayer, call setDisplay with the holder of this VideoView, etc., and ultimately the video plays well. When the video ends, I again switch the visibility - opengl to VISIBLE and video to INVISIBLE.

However, the problem is that when I try to play the video a second time, it just doesn’t appear, however the sound from the video is being played.

Is there a catch with visibility?

+5
source share
3

ApiDemo, , . : post ,

   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;
}
+3

Android MediaPlayer.

GLSurfaceView, Android, .

+1

, glview. ( ), - , . , . :

     // first set the content view as your glview with your params.
     setContentView(mGLView, gl_params);
     mGLView.setZOrderMediaOverlay(false);

     // add a parent view for video view. rl is relative layout
     addContentView(rl, rl_params);

     // now add the video view inside this parent view.
     rl.addview(video_view, video_view_params)
+1
source

All Articles