Android Question Viewing a video in realtime

AlpVir

Well-Known Member
Licensed User
Longtime User
Step 1
The following code displays a realtime video from a local IP webcam :
B4X:
webview1.Initialize("webview1")
Activity.AddView (webview1,0,0,100%x,100%y)
URL="http://admin:@192......1/video2.mjpg"     ' OK   (va bene in locale, con wifi
webview1.LoadUrl(URL)

Step 2
The following HTML code refers to a web page http: // ****** /test.html which displays the aforementioned video stream in realtime
The page can be viewed in any browser on a PC, but not on a smartphone (as far as I know)
B4X:
<!DOCTYPE html>
<html>
<head><meta http-equiv="Pragma" content="no-cache" /><meta http-equiv="Chache-Control" content="no-cache" /></head>
<body>
TEST 1<BR>
<iframe src="http://admin:@192.1.......1/video1.mjpg?autoplay=1&rel=1" width="800" height="640"></iframe>
</body>
</html>

Step 3
The following code B4A does NOT display the video, but only the word "TEST 1" followed by a white and empty box.
B4X:
webview1.Initialize("webview1")
Activity.AddView (webview1,0,0,100%x,100%y)
URL="http://*******/test.html"   
webview1.LoadUrl(URL)

Is there any way to view this video?
Thank you in advance
 

JohnC

Expert
Licensed User
Longtime User
Did you try adding the chromeclient to webview:

 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
Did you tried exoplayer?
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
@Biswajit : Yes, I have already tried ExoPlayer which however does not display HTML pages but only MP4 and the like.
@JohnC : Thanks but honestly I don't know how to use addWebChromeClient which I don't think is an event supported by WebViewExtras or WebViewExtras2. Furthermore, the second parameter should be a False or True, not a string.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Just add the WebViewExtras (v1.42) lib to your project, then add these lines before any wv.LoadURL or wv.LoadHTML:
B4X:
Dim wv as WebView
Dim wve as WebViewExtras  
wve.addWebChromeClient(wv, "WVE")

The "WVE" parameter is just the event name prefix for any webviewextras events (no events are triggered when just adding the chrome client)
 
Last edited:
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
Thanks but there is no change. "TEST 1" and the blank white box appear; no image or video ?
I seem to remember that Erel once wrote that webview is not suitable for viewing video streams. However I have experienced it, it is grateful to play an MP4 file.

B4X:
Dim URL                 As String
    Dim webview1             As WebView
    Dim WebViewExtras1         As WebViewExtras
    webview1.Initialize("webview1")
    Activity.AddView (webview1,0,0,100%x,100%y)
    URL="http://p***********i/c****.html"
    WebViewExtras1.addWebChromeClient(webview1, "WebViewExtras1")
    webview1.LoadUrl(URL)
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
As mentioned above I'm not sure if the webview component is suitable for this purpose.
But I can't find other ways.
I need to view an HTML page that includes a video stream. Do not directly view a video stream.
This is the very last link of a complex (for me) project that includes a rasperry connected to the web through a service like NoIP.com
How to solve ?
 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
Add this to manifest and enable JavaScript before loading url. Also add chromeclient and webviewclient
B4X:
SetApplicationAttribute(android:hardwareAccelerated, "true")

Check if this works or not.
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
Nothing !
I added the line to the manifest.
I also tried the AdvancedWebView library
Nothing !

B4X:
  Dim URL                 As String
    webview1.Initialize("")
    WebViewExtras1.Initialize(webview1)
    webview1.JavaScriptEnabled=True
    WebViewExtras1.JavaScriptEnabled=True

    Dim WebChromeClient1 As DefaultWebChromeClient
    WebChromeClient1.Initialize("WebChromeClient1")
    WebViewExtras1.SetWebChromeClient(WebChromeClient1)
 
    Dim WebViewClient1 As DefaultWebViewClient
    WebViewClient1.Initialize("WebViewClient1")
    WebViewExtras1.SetWebViewClient(WebViewClient1)
   
    Activity.AddView (webview1,0,0,100%x,100%y)
    URL="http://########/#######e.html"
    WebViewExtras1.LoadUrl(URL)
 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
Are you getting any log in b4a? check webview console outputs from chromeclient console message event.
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
Log
 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
Check the log.

Unsupported profile 4 for video/mp4v-es
HW encoder for video/avc is not available on this device.
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
Thanks for support.
However, the same smartphone displays a real-time video stream from another smartphone.
But use ImageView
So do you think it is impossible to view the video stream contained in an HTML page?

B4X:
    ImageView1.Initialize("ImageView1")
    Activity.AddView(ImageView1,0,0,100%x,100%y)
    mj1.Initialize(Me, "mj1")
    mj1.Connect("192.168.178.24/", 51042)
 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
Use exoplayer to view the video stream
 
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
To me it appears that exoplayer does NOT display HTML files but directly video streams or MP4 files
I know. You asked me,
So do you think it is impossible to view the video stream contained in an HTML page?

That's why I told you to use exoplayer. If you want to show the full html page then you have change the server video code, as you see in the log that your device doesn't support this kind of video format
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
you have change the server video code
The webcam operates in both MPEG and H.264. But I don't know how the Raspberry re-elaborates this video stream. How can I understand it?
In summary: a webcam (Dlink DCS 2130) on the local network creates a video stream; a Raspberry (always on the local network) receives it and is able to make it available on the internet through an HTML page whose local address is 192.168.xxx.x / cin.html
To do this, use a dynamic DNS of the type http://xxxxx.ddns.com/cin.html
Within the local network, this video can be viewed on any device. Outside no.
HTML pages residing on the Raspberry are seen correctly.
I would like to use a smartphone to see this video.
But incompatibility problems, not yet clear to me, prevent me.
Any other useful suggestions?
 
Upvote 0

max123

Well-Known Member
Licensed User
Longtime User

Not sure for this, with Google Nexus 7 2013 I show an html page exposed by ESP32CAM inside a regular WebView, it works even without use of WebViewExtras and without add a ChromeClient, inside this page there are camera controls and a button to start a stream of MJPEG video, it work very well on all resolutions from 160x120 to 1600x1200. The same code do not work on my Asus ZenFone2, tryed adding CromeClient bat without success, the page is loaded but return me this message:

header fields are too long for server to interpret

Suggestions to fix are very welcome.
Thanks
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…