Reputation: 627
I am trying to load a video in webview. It works fine.
However my video is being loaded in small size.
My code is below:
webView.loadData("<html><body> <script type='text/javascript'>ch='" + ChId + "'; ch_width=1080; ch_height=720;</script><script type='text/javascript' src='http://m.s247.tv/live.js'></script> </body></html>", "text/html; charset=utf-8", "UTF-8");
I want the video to fit the screen.
Upvotes: 0
Views: 1244
Reputation: 1092
Get the display width and height.
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int width = displayMetrics.widthPixels;
int height = displayMetrics.heightPixels;
Then in the web view, set the width and height:
webView.loadData("<html><body> <script type='text/javascript'>ch='" + ChId + "'; ch_width="+ width +"; ch_height=" + height" +";</script><script type='text/javascript' src='http://m.s247.tv/live.js'></script> </body></html>", "text/html; charset=utf-8", "UTF-8");
You can calculate aspect ratio too and set the height as aspect ratio.
Upvotes: 4