Issue
I have a webview that shows videos for the user to play and I can not see the poster. I'm using the follwoing webChromeClient:
myWebView.setWebChromeClient(new WebChromeClient() {
@Override
public Bitmap getDefaultVideoPoster() {
final Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
canvas.drawARGB(255, 255, 255, 255);
return bitmap;
}
public void onShowCustomView (View view, WebChromeClient.CustomViewCallback callback) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("video/*");
startActivity(intent);
}
public void onHideCustomView () {
}
});
I only see the white background.
Solution
You should return super.getDefaultVideoPoster()
, white poster occured because you overrided to draw white bitmap
@Override
public Bitmap getDefaultVideoPoster() {
//final Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565);
//Canvas canvas = new Canvas(bitmap);
//canvas.drawARGB(255, 255, 255, 255);
return super.getDefaultVideoPoster();
}
Edited:
You can work around: Add #t=1
after src
in html file <source src="xyz.mp4#t=1" type="video/mp4">
. It will show frame#1 as poster of video.
Answered By - Tung Tran
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.