Thanks everyone.
I have a TextureView
to show a video using MediaPlayer
.
Before the video is downloaded, I prefer to show a background color.
How to do that ?
My code below is not working :(
Screen is not updated 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);
}
Put your TextureView on a layout alone. And set the layouts background color the color you want. Also set TextureView opacity to null.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With