0

In webView, I am loading a html file. The file contains text, images and a youtube link. Text and the images are displayed just by loadUrl() method, but video is not being played. How should I get the link and play video.

Format in which link is present in html file is :

<p style="text-align: center; margin: 0px;">

        <iframe class="youtube-player" type="text/html" width="300" height="169" src="http://www.youtube.com/embed/4H0fTwtPLfo" allowfullscreen frameborder="0">

        </iframe>

        </p>

Please guide me.

EDIT

loading html file:

webView.loadUrl("file:///android_asset/"+htmlFile);
webView.setWebViewClient(new VideoWebViewClient());

VideoWebViewClient class:

private class VideoWebViewClient extends WebViewClient{

    @Override
    public boolean shouldOverrideUrlLoading(WebView webView, String url) {
        webView.loadUrl(url);
        return true;
    }

}

EDIT 2

I am able to play video by adding following lines of code:

WebSettings webSetting = webView.getSettings();
webSetting.setJavaScriptEnabled(true);
webSetting.setPluginState(WebSettings.PluginState.ON_DEMAND);
webSetting.setAllowContentAccess(true);

webView.loadUrl("file:///android_asset/"+htmlFile);
webView.setWebViewClient(new VideoWebViewClient());

I want to play video in full screen, but the full screen button freeze the video. Can anyone help?

megha
  • 301
  • 5
  • 18
  • is video display and not start automaticly or no display ? – erkan demir Jan 12 '15 at 12:26
  • 1
    possible duplicate of [YouTube Video not playing in WebView](http://stackoverflow.com/questions/17706580/youtube-video-not-playing-in-webview) – nwk Jan 12 '15 at 12:26
  • there is no diaplay. In place of video there is a black box. – megha Jan 12 '15 at 12:27
  • I am working with dynamic activity. Thus I don't have layout to add custom view as shown in example. I have tried with some code but it didn't help me. See my edit code and guide me. – megha Jan 12 '15 at 13:10

0 Answers0