Android MediaPlayer TextureView play video oom

488 views Asked by At

I use MediaPlayer & TextureView,Repeats the video. But within a short while the program crashed, cause by OOM. I called mediaPlayer.release() in onSurfaceTextureDestroyed(), but it still crashes.

Does any body has the same problem ?

This is my code :

    @Override
    public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
        surface=null;
        stop();
        try {
            mediaPlayer.release();

        }catch (Exception e){
        }
        return true;
    }

    private void stop(){

        try {
            if(!mediaPlayer.isPlaying()){
                return;
            }
            mediaPlayer.stop();
        }catch (Exception e){
        }
    }
0

There are 0 answers