Android Question Viewing a video in realtime

AlpVir

Well-Known Member
Licensed 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

Well-Known Member
Licensed User
Did you try adding the chromeclient to webview:

 

Biswajit

Active Member
Licensed User
Did you tried exoplayer?
 

AlpVir

Well-Known Member
Licensed 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.
 

JohnC

Well-Known Member
Licensed 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:

AlpVir

Well-Known Member
Licensed 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)
 

AlpVir

Well-Known Member
Licensed 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 ?
 

Biswajit

Active Member
Licensed 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.
 

AlpVir

Well-Known Member
Licensed 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)
 

Biswajit

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

AlpVir

Well-Known Member
Licensed User
Log
Logger connesso a: asus ASUS_Z00AD
--------- beginning of main
[16170] Initialize library(version: 5.0.7a_y.48167 RELEASE)... successfully.
SetAppTypeFace- try to flip, app = b4a.example
Typeface getFontPathFlipFont - systemFont = default#default
SetAppTypeFace- try to flip, app = b4a.example
Typeface getFontPathFlipFont - systemFont = default#default
common created.
Starting remote logger. Port: 35352
Render dirty regions requested: true
Validating map...
After accept
Initialized EGL, version 1.4
Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
Enabling debug mode 0
*** Debugger waiting for connection (0) ***
Application requested CPU execution
0xde108000 Launching thread(s), CPUs 4
*** Debugger waiting for connection (1) ***
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
primaryArchIs64bit = false
Loading com.google.android.webview version 83.0.4103.83 (code 410408351)
Loaded native library version number "83.0.4103.83"
Flushed 3 samples from 3 histograms.
validate_display:255 error 3008 (EGL_BAD_DISPLAY)
Requires BLUETOOTH permission
** Activity (main) Resume **
Unsupported profile 4 for video/mp4v-es
HW encoder for video/avc is not available on this device.
-1 received
writer error
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1991)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2025)
at java.util.concurrent.ArrayBlockingQueue.take(ArrayBlockingQueue.java:373)
at anywheresoftware.b4a.remotelogger.Connector$Writer.run(Connector.java:160)
at java.lang.Thread.run(Thread.java:818)
Starting remote logger. Port: 35352
After accept
 

Biswajit

Active Member
Licensed User
Check the log.

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

AlpVir

Well-Known Member
Licensed 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)
 

Biswajit

Active Member
Licensed User
Use exoplayer to view the video stream
 

Biswajit

Active Member
Licensed 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
 

AlpVir

Well-Known Member
Licensed 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?
 
Top