简体   繁体   中英

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 .

I want to display this content on a webpage, so I'm trying to use HTML5 to do so. I followed several questions here on SO that told me that both MPEG-1 and MPEG-2 were not supported. My supervisor told me that there is a way (probably a hack) to display the stream we want on a <video> tag. 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. 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.

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)

android:hardwareAccelerated="true"

(Android Manifest)

--

Any help displaying this feed on my Android device would be mostly appreciated.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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