简体   繁体   English

在Android WebView中使用HTML5视频标签显示MPEG流

[英]Displaying MPEG stream using HTML5 video tag inside an Android WebView

I'm trying to display a video feed coming from a netcam on my Android device using this URL: http://user:password@camera-ip:port/video.cgi . 我正在尝试使用以下URL在Android设备上显示来自网络http://user:password@camera-ip:port/video.cgi的视频供稿: http://user:password@camera-ip:port/video.cgi

I want to display this content on a webpage, so I'm trying to use HTML5 to do so. 我想在网页上显示此内容,所以我试图使用HTML5来显示。 I followed several questions here on SO that told me that both MPEG-1 and MPEG-2 were not supported. 我在SO上关注了几个问题,这些问题告诉我MPEG-1和MPEG-2均不受支持。 My supervisor told me that there is a way (probably a hack) to display the stream we want on a <video> tag. 我的主管告诉我,有一种方法(可能是黑客攻击)在<video>标签上显示我们想要的流。 It is as follows: 如下:

<html>
  <body>
    <video poster="http://user:password@camera-ip:port/video.cgi" controls autoplay></video>
  </body>
</html>

This works on Chrome, Firefox, and exceptionally well in Safari. 它可以在Chrome,Firefox和Safari上运行良好。 Not only do I fail to understand why adding the link in the poster makes for a functional solution (there is no source tag!) but also I am unable to run this inside an Android WebView. 我不仅不明白为什么在海报中添加链接可以实现功能解决方案(没有源标签!),而且我无法在Android WebView中运行它。

What I have tried: 我试过的

WebView webview = (WebView)findViewById(R.id.webview);
webview.setWebChromeClient(new WebChromeClient());
webview.getSettings().setJavaScriptEnabled(true); // this was for another attempt
webview.getSettings().setAllowFileAccess(true); // this was for another attempt

(Activity.java) (Activity.java)

android:hardwareAccelerated="true"

(Android Manifest) (Android清单)

-- -

Any help displaying this feed on my Android device would be mostly appreciated. 在我的Android设备上显示此供稿的任何帮助将不胜感激。

我设法通过开发API级别21(Lolipop)而不是API级别15(冰淇淋三明治)来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM