Esempio n. 1
0
 /**
  * \brief Pause the video
  */
 public void PauseVideo()
 {
     if (mPikkartVideoPlayer != null)
     {
         PikkartVideoPlayer.VideoSate.VIDEO_STATE status = mPikkartVideoPlayer.getVideoStatus();
         if (status == PikkartVideoPlayer.VideoSate.VIDEO_STATE.PLAYING)
         {
             mPikkartVideoPlayer.pause();
         }
     }
 }
Esempio n. 2
0
 /**
  * \brief Play/Pause the video
  */
 public void PlayOrPauseVideo()
 {
     if (mPikkartVideoPlayer != null)
     {
         PikkartVideoPlayer.VideoSate.VIDEO_STATE status = mPikkartVideoPlayer.getVideoStatus();
         if (status == PikkartVideoPlayer.VideoSate.VIDEO_STATE.PLAYING)
         {
             mPikkartVideoPlayer.pause();
         }
         else if (status == PikkartVideoPlayer.VideoSate.VIDEO_STATE.END ||
                  status == PikkartVideoPlayer.VideoSate.VIDEO_STATE.PAUSED ||
                  status == PikkartVideoPlayer.VideoSate.VIDEO_STATE.READY ||
                  status == PikkartVideoPlayer.VideoSate.VIDEO_STATE.STOPPED)
         {
             mPikkartVideoPlayer.play();
         }
     }
 }
Esempio n. 3
0
        /**
         * \brief Draw the video mesh /with keyframe and icons too) (in OpenGL).
         * @param modelView the model-view matrix.
         * @param projection the projection matrix.
         */
        public void DrawMesh(float[] modelView, float[] projection)
        {
            PikkartVideoPlayer.VideoSate.VIDEO_STATE currentStatus = PikkartVideoPlayer.VideoSate.VIDEO_STATE.NOT_READY;
            if (mPikkartVideoPlayer != null)
            {
                currentStatus = mPikkartVideoPlayer.getVideoStatus();
                if (!mPikkartVideoPlayer.isFullscreen())
                {
                    if (mPikkartVideoPlayer.getVideoStatus() == PikkartVideoPlayer.VideoSate.VIDEO_STATE.PLAYING)
                    {
                        mPikkartVideoPlayer.updateVideoData();
                    }
                    mPikkartVideoPlayer.getSurfaceTextureTransformMatrix(mTexCoordTransformationMatrix);
                    SetVideoDimensions(mPikkartVideoPlayer.getVideoWidth(), mPikkartVideoPlayer.getVideoHeight(), mTexCoordTransformationMatrix);
                    mVideoTexCoords_Buffer = FillBuffer(videoTextureCoordsTransformed);
                }
            }

            Marker currentMarker = RecognitionFragment.CurrentMarker;

            if (currentMarker != null)
            {
                float markerWidth  = currentMarker.Width;
                float markerHeight = currentMarker.Height;

                GLES20.GlEnable(GLES20.GlDepthTest);
                //GLES20.GlDisable(GLES20.GlCullFaceMode);
                GLES20.GlCullFace(GLES20.GlBack);
                GLES20.GlFrontFace(GLES20.GlCw);

                if ((currentStatus == PikkartVideoPlayer.VideoSate.VIDEO_STATE.READY) ||
                    (currentStatus == PikkartVideoPlayer.VideoSate.VIDEO_STATE.END) ||
                    (currentStatus == PikkartVideoPlayer.VideoSate.VIDEO_STATE.NOT_READY) ||
                    (currentStatus == PikkartVideoPlayer.VideoSate.VIDEO_STATE.ERROR))
                {
                    float[] scaleMatrix = new float[16];
                    RenderUtils.matrix44Identity(scaleMatrix);
                    scaleMatrix[0]  = markerWidth;
                    scaleMatrix[5]  = markerWidth * keyframeAspectRatio;
                    scaleMatrix[10] = markerWidth;

                    float[] temp_mv = new float[16];
                    RenderUtils.matrixMultiply(4, 4, modelView, 4, 4, scaleMatrix, temp_mv);

                    float[] temp_mvp = new float[16];
                    RenderUtils.matrixMultiply(4, 4, projection, 4, 4, temp_mv, temp_mvp);
                    float[] mvpMatrix = new float[16];
                    RenderUtils.matrix44Transpose(temp_mvp, mvpMatrix);

                    DrawKeyFrame(mvpMatrix);
                }
                else
                {
                    float[] scaleMatrix = new float[16];
                    RenderUtils.matrix44Identity(scaleMatrix);
                    scaleMatrix[0]  = markerWidth;
                    scaleMatrix[5]  = markerWidth * videoAspectRatio;
                    scaleMatrix[10] = markerWidth;

                    float[] temp_mv = new float[16];
                    RenderUtils.matrixMultiply(4, 4, modelView, 4, 4, scaleMatrix, temp_mv);

                    float[] temp_mvp = new float[16];
                    RenderUtils.matrixMultiply(4, 4, projection, 4, 4, temp_mv, temp_mvp);
                    float[] mvpMatrix = new float[16];
                    RenderUtils.matrix44Transpose(temp_mvp, mvpMatrix);

                    DrawVideo(mvpMatrix);
                }

                if ((currentStatus == PikkartVideoPlayer.VideoSate.VIDEO_STATE.READY) ||
                    (currentStatus == PikkartVideoPlayer.VideoSate.VIDEO_STATE.END) ||
                    (currentStatus == PikkartVideoPlayer.VideoSate.VIDEO_STATE.PAUSED) ||
                    (currentStatus == PikkartVideoPlayer.VideoSate.VIDEO_STATE.NOT_READY) ||
                    (currentStatus == PikkartVideoPlayer.VideoSate.VIDEO_STATE.ERROR))
                {
                    float[] translateMatrix = new float[16];
                    RenderUtils.matrix44Identity(translateMatrix);
                    //scale a bit
                    translateMatrix[0]  = 0.4f;
                    translateMatrix[5]  = 0.4f;
                    translateMatrix[10] = 0.4f;
                    //translate a bit
                    translateMatrix[3]  = 0.0f;
                    translateMatrix[7]  = 0.45f;
                    translateMatrix[11] = -0.05f;

                    float[] temp_mv = new float[16];
                    RenderUtils.matrixMultiply(4, 4, modelView, 4, 4, translateMatrix, temp_mv);

                    float[] temp_mvp = new float[16];
                    RenderUtils.matrixMultiply(4, 4, projection, 4, 4, temp_mv, temp_mvp);
                    float[] mvpMatrix = new float[16];
                    RenderUtils.matrix44Transpose(temp_mvp, mvpMatrix);

                    DrawIcon(mvpMatrix, currentStatus);
                }
                RenderUtils.CheckGLError("VideoMesh:end video renderer");
            }
        }
Esempio n. 4
0
        /**
         * \brief Draw the video icon (in OpenGL).
         * @param mvpMatrix the model-view-projection matrix.
         * @param status the video state.
         */
        private void DrawIcon(float[] mvpMatrix, PikkartVideoPlayer.VideoSate.VIDEO_STATE status)
        {
            GLES20.GlEnable(GLES20.GlBlend);
            GLES20.GlBlendFunc(GLES20.GlSrcAlpha, GLES20.GlOneMinusSrcAlpha);

            GLES20.GlUseProgram(mKeyframe_Program_GL_ID);

            int vertexHandle       = GLES20.GlGetAttribLocation(mKeyframe_Program_GL_ID, "vertexPosition");
            int textureCoordHandle = GLES20.GlGetAttribLocation(mKeyframe_Program_GL_ID, "vertexTexCoord");
            int mvpMatrixHandle    = GLES20.GlGetUniformLocation(mKeyframe_Program_GL_ID, "modelViewProjectionMatrix");
            int texSampler2DHandle = GLES20.GlGetUniformLocation(mKeyframe_Program_GL_ID, "texSampler2D");

            GLES20.GlVertexAttribPointer(vertexHandle, 3, GLES20.GlFloat, false, 0, mVertices_Buffer);
            GLES20.GlVertexAttribPointer(textureCoordHandle, 2, GLES20.GlFloat, false, 0, mTexCoords_Buffer);

            GLES20.GlEnableVertexAttribArray(vertexHandle);
            GLES20.GlEnableVertexAttribArray(textureCoordHandle);

            GLES20.GlActiveTexture(GLES20.GlTexture0);
            switch ((int)status)
            {
            case 0:    //end
                GLES20.GlBindTexture(GLES20.GlTexture2d, mIconPlayTexture_GL_ID);
                break;

            case 1:    //pasued
                GLES20.GlBindTexture(GLES20.GlTexture2d, mIconPlayTexture_GL_ID);
                break;

            case 2:    //stopped
                GLES20.GlBindTexture(GLES20.GlTexture2d, mIconPlayTexture_GL_ID);
                break;

            case 3:    //playing
                GLES20.GlBindTexture(GLES20.GlTexture2d, mIconPlayTexture_GL_ID);
                break;

            case 4:    //ready
                GLES20.GlBindTexture(GLES20.GlTexture2d, mIconPlayTexture_GL_ID);
                break;

            case 5:    //not ready
                GLES20.GlBindTexture(GLES20.GlTexture2d, mIconBusyTexture_GL_ID);
                break;

            case 6:    //buffering
                GLES20.GlBindTexture(GLES20.GlTexture2d, mIconBusyTexture_GL_ID);
                break;

            case 7:    //error
                GLES20.GlBindTexture(GLES20.GlTexture2d, mIconErrorTexture_GL_ID);
                break;

            default:
                GLES20.GlBindTexture(GLES20.GlTexture2d, mIconBusyTexture_GL_ID);
                break;
            }
            GLES20.GlUniform1i(texSampler2DHandle, 0);

            GLES20.GlUniformMatrix4fv(mvpMatrixHandle, 1, false, mvpMatrix, 0);


            GLES20.GlDrawElements(GLES20.GlTriangles, mIndices_Number, GLES20.GlUnsignedShort, mIndex_Buffer);

            GLES20.GlDisableVertexAttribArray(vertexHandle);
            GLES20.GlDisableVertexAttribArray(textureCoordHandle);

            GLES20.GlUseProgram(0);
            GLES20.GlDisable(GLES20.GlBlend);
        }