Android Question Issue with Fullscreen Video in UltimateWebView2 library

Mattiaf

Active Member
Licensed User
I'm trying to enable the fullscreen mode for video players on various websites using Ivica Golubovic's "UltimateWebView2" library in B4A. Here's the code I'm using:

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Settings As WebSettings
    Private CookieM As CookieManager
    Private WebViewClient As UltimateWebViewClient
    Private WebChromeClient As UltimateWebChromeClient

    Public WebView1 As WebView ' Object added through Designer
End Sub

Public Sub Initialize
    ' B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
   
    WebViewClient.Initialize2("WebView1", WebView1)
    WebChromeClient.Initialize2("WebView1", WebView1).AllowFullScreenVideo(True, False) 'AllowFullScreenVideo only if you need, it is not necessary to set.
   
    Settings.Initialize(WebView1)
    CookieM.Initialize(WebView1)
   
    Settings.AllowContentAccess = True
    Settings.AllowFileAccess = False
    Settings.AllowFileAccessFromFileURLs = False
    Settings.AllowUniversalAccessFromFileURLs = True
    Settings.BuiltInZoomControls = False
    Settings.JavaScriptEnabled = True
    Settings.DomStorageEnabled = True
    Settings.JavaScriptCanOpenWindowsAutomatically = False
    Settings.MediaPlaybackRequiresUserGesture = False
    Settings.SaveFormData = True
    Settings.GeolocationEnabled = False
    Settings.SupportMultipleWindows = True
    CookieM.AcceptCookies = True
    CookieM.AcceptFileSchemeCookies = True
    CookieM.AcceptThirdPartyCookies = False
    WebView1.LoadUrl("https://www.animesaturn.in/")
End Sub

Private Sub WebView1_CreateWindow (OverridenRequest As WebResourceRequest, ChildWebView As WebView, IsDialog As Boolean, IsUserGesture As Boolean) As Boolean 'Works from API level 1 and above. Return True if you want to consume ChildWebView, False to destroy. SupportMultipleWindows option must be enabled. You can add the newly created WebViewObject to Layout manualy, or use UltimateWebView's AddChildWindow method.
    Log("WebkitWebView1_CreateWindow")
    If IsUserGesture = False Then Return False 'Try to prevent an unwanted commercial popup's.
    Return True
End Sub

However, if I set #SupportedOrientations: portrait, the video, once I click on the fullscreen button, will be displayed in portrait mode regardless of whether I switch the screen orientation to landscape from the phone's dropdown menu. On the other hand, if I set #SupportedOrientations: landscape, everything will be displayed in landscape mode even if my phone is in portrait orientation. Also, the library print at debug a log where it says to set either landscape or portrait, thus unspecified, which would be great for me, isn't supported :( . . This is quite a headache, and I can't seem to find a solution. The library "should" handle fullscreen video in this manner for online videos. The issue occurs regardless of the video player.
Unfortunately I' havent been able to implement SoftOrientation Library not because it's difficult or what, but because of the moltitude of cases and I don't know which code suits mostmy case scenario.
Any suggestions on how to resolve this orientation issue while keeping fullscreen video functional?

Thanks in advance!
 
Last edited:

Mattiaf

Active Member
Licensed User
Anyone could help ? Cant believe such a "silly" thing is kinda impossible to do without a 3rd party lib...
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
B4X:
Settings.UseWideViewPort = True
?
 
Upvote 0
Top