任何人都可以指导我如何在Web视图中调整视频大小(适合屏幕和全屏)。 我试图从Android应用程序中的通道的嵌入链接流这里是代码片段
String playVideo= "<html><body><iframe type=\"text/html\" width=\"350\" height=\"235\"src=\"http:www.skyembed.com/skysports1.php\" frameborder=\"0\"></body></html>"; webView.loadData(playVideo, "text/html", "utf-8");提前
Can anyone please guide me on how to resize video(fit to screen and full screen) in web view. I am trying to stream from embed link of channels in android app here is code snippet
String playVideo= "<html><body><iframe type=\"text/html\" width=\"350\" height=\"235\"src=\"http:www.skyembed.com/skysports1.php\" frameborder=\"0\"></body></html>"; webView.loadData(playVideo, "text/html", "utf-8");thanx in advance
最满意答案
如果您要将WebView或iframe调整为全屏,则可以使用:
在布局xml中
<WebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/webView" ></WebView>在java源码中:
WebView webView=(WebView)findViewById(R.id.ww); // **** use width="100%" and height="100%" to fill the webview by iFrame ****** String playVideo= "<html><body><iframe type=\"text/html\" width=\"100%\" height=\"100%\"src=\"http:www.skyembed.com/skysports1.php\" frameborder=\"0\"></body></html>"; webView.loadData(playVideo, "text/html", "utf-8");但如果你的意思是在http:www.skyembed.com/skysports1.php调整src元素的大小。 这不可能。 这必须从服务器端完成。通过添加这样的javaScript:
var elem = document.getElementById("myFrame"); if (elem.requestFullscreen) { elem.requestFullscreen(); }如果你需要使用流媒体视频,最好的方法是使用MediaPlayer 。 如何在Android应用程序中播放实时流媒体?
If you mean resizing the WebView or iframe to full screen, you can use this :
in layout xml
<WebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/webView" ></WebView>in java source :
WebView webView=(WebView)findViewById(R.id.ww); // **** use width="100%" and height="100%" to fill the webview by iFrame ****** String playVideo= "<html><body><iframe type=\"text/html\" width=\"100%\" height=\"100%\"src=\"http:www.skyembed.com/skysports1.php\" frameborder=\"0\"></body></html>"; webView.loadData(playVideo, "text/html", "utf-8");but if you mean resizing the src elements in http:www.skyembed.com/skysports1.php . it is not possible. this has to done from server side .by adding a javaScript like this :
var elem = document.getElementById("myFrame"); if (elem.requestFullscreen) { elem.requestFullscreen(); }finallay if you need to paly a streamed video , best way is using MediaPlayer. How to play live streaming in android application?
更多推荐
发布评论