In recent months almost half of all local Dutch TV stations have switched to HTML5 to stream their programs. I have managed to get a HTML5 TV player working on the basis of:
www.b4x.com
The only problem is that the sound of nearly all stations is muted once the player starts. The user has to press the loudspeaker button to listen to the sound.
I have temporarily solved it by simulating two mouse clicks (using gesturedetector): the first click is to make the controls appear and the second is to click on the loudspeaker button. It works, but is rather clumsey and probably won't work on screens with different aspect ratio.
Can someone please make a javascript that automatically clicks on the loudspeaker button once the webview pagefinished event has fired? In the html source the code "mute=muted" then disappears. Here is my code:
Simple HTML5 app wrapper
I put together a little app to wrap an HTML5 app in B4A. Of course you could do this with phonegap, or something else, but you get a lot more power and control using B4A. Using jsinterface from webviewextras, you can interact between B4A code and your HTML5/js app. This opens up the full...

I have temporarily solved it by simulating two mouse clicks (using gesturedetector): the first click is to make the controls appear and the second is to click on the loudspeaker button. It works, but is rather clumsey and probably won't work on screens with different aspect ratio.
Can someone please make a javascript that automatically clicks on the loudspeaker button once the webview pagefinished event has fired? In the html source the code "mute=muted" then disappears. Here is my code:
HTML5 TV player:
Sub Process_Globals
Dim GestDet1 As GestureDetector
End Sub
Sub Globals
Dim Webview1 As WebView
Dim WebviewExtras1 As WebViewExtras
Dim WebViewSettings1 As WebViewSettings
End Sub
Sub Activity_Create(FirstTime As Boolean)
Webview1.Initialize("Webview1")
WebviewExtras1.addWebChromeClient(Webview1,"WebviewExtras1")
' WebViewSettings1.setAllowFileAccess(Webview1,True) 'Not needed!
' WebViewSettings1.setAppCacheEnabled(Webview1,True) 'Not needed!
WebViewSettings1.setDOMStorageEnabled(Webview1,True) 'Needed!
Activity.AddView(Webview1,0,5%y,100%x,100%y) 'All these streams work, but are muted:
'Webview1.LoadUrl("https://wl-0d171e.enigmatv.io/play/anonymous/f80cee88_0D171E") 'RTV Purmerend
'Webview1.LoadUrl("https://wl-0d171e.enigmatv.io/play/anonymous/fc53f324_0D171E") 'RTV Krimpenerwaard
'Webview1.LoadUrl("https://wl-0d171e.enigmatv.io/play/anonymous/88729a5a_0D171E") 'Schie TV
'Webview1.LoadUrl("https://wl-0d171e.enigmatv.io/play/anonymous/478ebcbd_0D171E") 'RTV Bodegraven
'Webview1.LoadUrl("https://wl-0d171e.enigmatv.io/play/anonymous/387cc0bd_0D171E") 'RTV Meppel
Webview1.LoadUrl("https://wl-0d171e.enigmatv.io/play/anonymous/0d8a1afd_0D171E") 'RTV IJsselmond
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Webview1_PageFinished (Url As String) 'Event
Log("Webview1 Page Finished")
Sleep(250)
Dim MEv As Object = GestDet1.CreateMotionEvent(DateTime.Now,DateTime.Now,GestDet1.ACTION_DOWN,50%x,50%y) 'Simulate click event to show the player controls
GestDet1.PassTouchEventTo(MEv, Webview1)
Dim MEv As Object = GestDet1.CreateMotionEvent(DateTime.Now,DateTime.Now,GestDet1.ACTION_UP,50%x,50%y)
GestDet1.PassTouchEventTo(MEv, Webview1)
Sleep(500)
Dim MEv As Object = GestDet1.CreateMotionEvent(DateTime.Now,DateTime.Now,GestDet1.ACTION_DOWN,18.3%x,91.1%y) 'Simulate click event to start playing (unmute)!
GestDet1.PassTouchEventTo(MEv, Webview1)
Dim MEv As Object = GestDet1.CreateMotionEvent(DateTime.Now,DateTime.Now,GestDet1.ACTION_UP,18.3%x,91.1%y)
GestDet1.PassTouchEventTo(MEv, Webview1)
Return
Dim Javascript As String 'Experiment, does not work
Javascript = "document.getElementById('player1594582608592_empHLS-MSE_api').setAttribute('muted','unmuted'); "
WebviewExtras1.ExecuteJavascript(Webview1,Javascript)
End Sub
Last edited: