I have a MediaPlayer rendering videos to a TextureView. This is working.
Now, I want to display a still image on this TextureView for a given time, then get the MediaPlayer to render a video to the same TextureView.
Here's my code to render the bitmap:
Canvas canvas = mTextureView.lockCanvas();
canvas.drawBitmap(sourceBitmap, matrix, new Paint());
mTextureView.unlockCanvasAndPost(canvas);
After this, any attempts to play videos result in ERROR_INVALID_OPERATION (-38) being triggered from the video player.
I tried commenting out the call to drawBitmap, and the error still happened. It seems that the simple act of calling lockCanvas followed by unlockCanvasAndPost results in the TextureView being unsuitable for the MediaPlayer to use.
Is there some way that I can reset the TextureView to a state that allows the MediaPlayer to use it?
I'm working on Android 4.2.2.