Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

playing video on top of OpenGL view in android

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?

like image 649
Dmitry Avatar asked Feb 06 '12 03:02

Dmitry


2 Answers

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;
}
like image 182
Sudar Nimalan Avatar answered Oct 20 '22 03:10

Sudar Nimalan


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.

like image 24
Aqif Hamid Avatar answered Oct 20 '22 04:10

Aqif Hamid