Android TextureView sets the background color and shows the video later

Thanks to everyone.
I have a TextureView to show a video using MediaPlayer . Before downloading the video, I prefer to show the background color. How to do it?

My code below does not work :(
The screen does not refresh after play is called

 public void play(String filename) { try { mPlayer.setDataSource(filename); mPlayer.setSurface(new Surface(getSurfaceTexture())); mPlayer.prepare(); mPlayer.setLooping(true); mPlayer.start(); } catch (IOException e) { Log.e("@", "fail to play video"); } } public void setPlaceholderColor(int color) { Canvas canvas = lockCanvas(); canvas.drawColor(color); unlockCanvasAndPost(canvas); } 
+7
android
source share
1 answer

Place your TextureView only on the layout. And set the background color of the layout to the desired color. Also set the opacity of the TextureView to null.

+1
source share

All Articles