youtube视频没有在iframe的android webview中播放

时间:2022-02-14 20:27:55

I am developing an android application.

我正在开发一个Android应用程序。

This is my xml feed tag:

这是我的xml feed标记:

<FullContent>
  <style> img {padding:2px;} p{color:#fff} </style>
   <p> Actor Hrithik Roshan has always nursed a</p> <br/><br/><br/><br/><br/>
   <p style=font-size:12px>@Notch 2013</p>
    <iframe src="http://www.youtube.com/embed/k8T3_JupGhI?fs=0" 
     width="500" height="298" frameborder="0"></iframe>
     </FullContent>

I am trying to play the video in android WebView with following code -

我正在尝试使用以下代码在Android WebView中播放视频 -

  content = (WebView) findViewById(R.id.fullcontent);
  content.setWebChromeClient(new WebChromeClient());
   content.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
   content.getSettings().setJavaScriptEnabled(true);
    content.getSettings().setDomStorageEnabled(true);
     content.getSettings().setPluginsEnabled(true);
       String fullcontent = in.getStringExtra("FullContent");
         full_content=fullcontent.substring(1);
          content.loadDataWithBaseURL(null,full_content, "text/html", "UTF-8",null);

But when I click on it the video is not playing.

但是当我点击它时,视频没有播放。

What is wrong with my code ?

我的代码出了什么问题?

EDIT:

编辑:

    I have added below code on my android app

    web.getSettings().setPluginState(PluginState.ON_DEMAND);
    web.getSettings().setPluginState(PluginState.ON);
    web.getSettings().setPluginsEnabled(true);

now also I am facing same problem.The video is opened. But when I click on it the video is not playing.

现在我也面临同样的问题。视频已经打开。但是当我点击它时,视频没有播放。

1 个解决方案

#1


0  

Don't try to include iframe but simply provide a thumbnail of the video which directly links to YouTube page or h264 file.

不要尝试包含iframe,只需提供直接链接到YouTube页面或h264文件的视频缩略图。

Earlier discussion, with a possible solution.

早期的讨论,有一个可能的解决方案。

#1


0  

Don't try to include iframe but simply provide a thumbnail of the video which directly links to YouTube page or h264 file.

不要尝试包含iframe,只需提供直接链接到YouTube页面或h264文件的视频缩略图。

Earlier discussion, with a possible solution.

早期的讨论,有一个可能的解决方案。