Code example for MediaPlayer

Methods: setSurface

0
 
        _mySurfaceTexture = new SurfaceTexture(_myTextureId[0]);
        _mySurfaceTexture.setOnFrameAvailableListener(this);
 
        Surface mySurface = new Surface(_mySurfaceTexture);
        _myMediaPlayer = new MediaPlayer();
        _myMediaPlayer.setSurface(mySurface);
        mySurface.release();
        // TODO: switch to async 
        //_myMediaPlayer.setOnPreparedListener(this); 
    } 
 
    // Called when MediaPlayer is ready 
    public void onPrepared(MediaPlayer player) {
        //player.start(); 
 
    } 
 
    synchronized public void onFrameAvailable(SurfaceTexture surface) {
        _myUpdateSurfaceFlag = true;
    }