nullByte nullByte - 3 months ago 25
Java Question

android live streaming app using embed code

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

Answer

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?