1

I have a WebView that is loading html tags using loaddata method .All the tags are getting rendered except the videourl. Can some one help me out?

htmlstring="<html> <head> <link href="http://amp.azure.net/libs/amp/1.7.1/skins/amp-default/azuremediaplayer.min.css" rel="stylesheet"> <script src="http://amp.azure.net/libs/amp/1.7.1/azuremediaplayer.min.js"></script> </head> <body> <h1>Skill Cloud</h1> <video id="azuremediaplayer" class="azuremediaplayer amp-default-skin amp-big-play-centered" tabindex="0" data-setup='{"techOrder": ["azureHtml5JS", "flashSS", "html5FairPlayHLS","silverlightSS", "html5"], "nativeControlsForTouch": false}'> </video> <script> var myOptions = { autoplay: false, controls: true, width: "100%", height: "auto", poster: "" }; var myPlayer = amp("azuremediaplayer", myOptions); myPlayer.src([{ src: "http://amssamples.streaming.mediaservices.windows.net/91492735-c523-432b-ba01-faba6c2206a2/AzureMediaServicesPromo.ism/manifest", type: "application/vnd.ms-sstr+xml" }, ]); </script> <br /> <p>© Microsoft Corporation 2016</p> <video id="azuremediaplayer" class="azuremediaplayer amp-default-skin amp-big-play-centered" controls autoplay width="640" height="400" poster="" data-setup='{}' tabindex="0"> <source src="http://b028.wpc.azureedge.net/80B028/Samples/a38e6323-95e9-4f1f-9b38-75eba91704e4/5f2ce531-d508-49fb-8152-647eba422aec.ism/manifest" type="application/vnd.ms-sstr+xml" /> <p class="amp-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video</p> </video> </body> </html>" 

mWebView.loadData(htmlstring, "text/html; charset=UTF-8", null);

The video source url is not getting rendered

1 Answer 1

11

you have enabled javascript ?

yourWebViewb.getSettings().setJavaScriptEnabled(true);

EDIT:

I've tested your code and it works for me this way

    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    webview.getSettings().setBuiltInZoomControls(false);
    webview.getSettings().setLoadWithOverviewMode(true);
    webview.getSettings().setLoadsImagesAutomatically(true);

    webview.getSettings().setUseWideViewPort(true); 
    webview.setWebChromeClient(new WebChromeClient()); 

    String htmlstring = "<html> <head> <link href=\"http://amp.azure.net/libs/amp/1.7.1/skins/amp-default/azuremediaplayer.min.css\" rel=\"stylesheet\"> <script src=\"http://amp.azure.net/libs/amp/1.7.1/azuremediaplayer.min.js\"></script> </head> <body> <h1>Skill Cloud</h1> <video id=\"azuremediaplayer\" class=\"azuremediaplayer amp-default-skin amp-big-play-centered\" tabindex=\"0\" data-setup='{\"techOrder\": [\"azureHtml5JS\", \"flashSS\", \"html5FairPlayHLS\",\"silverlightSS\", \"html5\"], \"nativeControlsForTouch\": false}'> </video> <script> var myOptions = { autoplay: false, controls: true, width: \"100%\", height: \"auto\", poster: \"\" }; var myPlayer = amp(\"azuremediaplayer\", myOptions); myPlayer.src([{ src: \"http://amssamples.streaming.mediaservices.windows.net/91492735-c523-432b-ba01-faba6c2206a2/AzureMediaServicesPromo.ism/manifest\", type: \"application/vnd.ms-sstr+xml\" }, ]); </script> <br /> <p>© Microsoft Corporation 2016</p> <video id=\"azuremediaplayer\" class=\"azuremediaplayer amp-default-skin amp-big-play-centered\" controls autoplay width=\"640\" height=\"400\" poster=\"\" data-setup='{}' tabindex=\"0\"> <source src=\"http://b028.wpc.azureedge.net/80B028/Samples/a38e6323-95e9-4f1f-9b38-75eba91704e4/5f2ce531-d508-49fb-8152-647eba422aec.ism/manifest\" type=\"application/vnd.ms-sstr+xml\" /> <p class=\"amp-no-js\">To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video</p> </video> </body> </html>";
    webview.loadDataWithBaseURL(null, htmlstring, null, "UTF-8", null);

I tried load data with "loadData" but not work use instead "loadDataWithBaseURL", try my code, works for me in android 4.2

Sign up to request clarification or add additional context in comments.

4 Comments

I enabled setjavascript apart from this im using below settings for webview setRenderPriority(WebSettings.RenderPriority.HIGH); s.setBuiltInZoomControls(false); s.setLoadWithOverviewMode(true); s.setLoadsImagesAutomatically(true); s.setJavaScriptEnabled(true);
webview.loadurl() is working fine but the issue is with loading html tags of that page
Look my edit. I do not know if it's the right way, but it works for me.
I used the same code in version 5+ devices i could just see some grey play button and the video is not getting played.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.