B4J Question WebView - YouTube error ?

Patent

Member
Licensed User
Longtime User
Dear Community,

wanna play a Youtube Video in a B4J WebView:

B4X:
    Dim mywebview As WebView
    mywebview.Initialize("myww")
    MainForm.RootPane.AddNode(mywebview,100,100,500,800)
    mywebview.Visible=True

    mywebview.LoadHtml( _
    $"<!DOCTYPE html>
<html>
<body>
<iframe width="420" height="345" src="https://www.youtube.com/embed/QVHhnDdjlfo">
</iframe>
</body>
</html>"$)

this gets the error: Video not available.... (first frame is visible for 0.5sec!)

same code in i.e. Firefox Browser works.

Any ideas?

gereets
patent
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Works fine. Tested with this code:
B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private WebView1 As WebView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.RootPane.LoadLayout("1") 'Load the layout file.
   MainForm.Show
   WebView1.LoadUrl("https://www.youtube.com/watch?v=vog7PmCPG5w")
End Sub
 
Upvote 0

Patent

Member
Licensed User
Longtime User
Thank you Erel.
You are right, but i want to do it with HTML to get more control about the "design" of the player.

this video-id is not working:
<iframe width="560" height="315" src="https://www.youtube.com/embed/QVHhnDdjlfo" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

this works:
<iframe width="560" height="315" src="https://www.youtube.com/embed/Iukmp8INeO8" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Maybe it is because of "embeding" settings. But it should not.


Any possibility to get more control with the ...LoadUrl solution?
 
Upvote 0
Top