iOS Question WKWebView and allowsInlineMediaPlayback property?

Discussion in 'iOS Questions' started by sidrol, Apr 17, 2019.

  1. sidrol

    sidrol New Member Licensed User

    I want to use the WKWebView for a project, but I also need to be able to play videos inside webpages, not full screen.
    In the old WebView I could set a NativeObject field as this:
    Dim no As NativeObject = WebView1
    no.SetField("allowsInlineMediaPlayback", True)

    But with the new WKWebView this doesn't work, it seems like this setting is behind some config ( Anyone have a clue how to manage this with WKWebView?

  2. Erel

    Erel Administrator Staff Member Licensed User

    Sub Process_Globals
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private WKWebView1 As WKWebView
    End Sub

    Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
       NavControl = Nav
       Page1.RootPanel.Color = 
       WKWebView1 = CreateWKWebView(Page1.RootPanel)
    End Sub

    Sub CreateWKWebView (pnl As PanelAs View
    Dim conf As NativeObject
       conf = conf.Initialize(
    Dim wk As NativeObject
    Dim p As NativeObject = pnl
       wk = wk.Initialize(
    "initWithFrame:configuration:"Array(p.RunMethod("frame"Null), conf))
    00, pnl.Width, pnl.Height)
    Return wk
    End Sub

    Private Sub Page1_Resize(Width As Int, Height As Int)
    Dim v As View = WKWebView1
    0100, Width, Height)
    End Sub
    I don't see any difference in the behavior.
  3. sidrol

    sidrol New Member Licensed User

    Thank you! This worked perfectly for me!

    Also, now I understand more how to invoke core functionality :)

  4. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    Do i need to put the WKWebView inside a panel to get this to work ? i already added the
    WKWebView in the designer so ...
  5. Erel

    Erel Administrator Staff Member Licensed User

    This code creates a new WKWebView, this means that you should NOT create one with the designer. You can add a panel with the designer and then use this code to put a WKWebview on that panel.
  6. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    Yup thats what i did :D
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice