2022-04-25, 08:40:43
Hi,
I'm not able to reproduce this.
FWIW, I have the following code:
Pressing the PlayerTimeButton will always return a debugPrint of "1" which makes sense as the object isn't created.
If you can't fix it, then please give me a way to reproduce your problem (aka.. zip your frm/frx in a minimal reproducable case)
--
Wil
I'm not able to reproduce this.
FWIW, I have the following code:
Code:
Option Explicit
Public WithEvents Document As AntviewAx.AntViewDocument
Private Sub Command1_Click()
'
Document.RequestCurrentHtml
' the result comes back via the Document_OnRequestHtml event below
End Sub
Private Sub Document_OnRunAnonymousFunction(ByVal Id As Long, ByVal Params As Variant, ByVal Data As String, ByVal Error As Long)
If Id = 1 Then
Debug.Print "AppStyle = " & Data
End If
If Id = 2 Then
Debug.Print "PlayerTime = " & Data
End If
End Sub
Private Sub EdgeWebBrowser_OnCreateWebviewCompleted(ByVal HResult As Long)
MapLocalFolderToHostName
End Sub
Private Sub Document_OnRequestCurrentHtml(ByVal Html As String)
MsgBox Html
End Sub
' show how-to read appStyle using anonymous functions
Private Sub readAppStyleVariable()
Dim Script As String
Dim Params As Variant
Script = " () => {" & vbCrLf
Script = Script & " let appStyle = '';" & vbCrLf
Script = Script & " let app = document.getElementById('cip-hosted-payments-app');" & vbCrLf
Script = Script & " if (app !== null) {" & vbCrLf
Script = Script & " appStyle = app.style.display;" & vbCrLf
Script = Script & " if (appStyle !== null) {" & vbCrLf
Script = Script & " return appStyle;" & vbCrLf
Script = Script & " } else {" & vbCrLf
Script = Script & " return 'null';" & vbCrLf
Script = Script & " }" & vbCrLf
Script = Script & " } else {" & vbCrLf
Script = Script & " return '1';" & vbCrLf
Script = Script & " }" & vbCrLf
Script = Script & "}" & vbCrLf
' connect document
Document.BrowserDispatch (EdgeWebBrowser.Dispatch)
' run the above as anonymous function 1
Document.RunAnonymousFunction 1, Params, Script
End Sub
' read Player timer
Private Sub readPlayerCurrentTime()
Dim Script As String
Dim Params As Variant
Script = " () => {" & vbCrLf
Script = Script & " let playerTime = '';" & vbCrLf
Script = Script & " let app = document.getElementById('veoplayer_html5_api');" & vbCrLf
Script = Script & " if (app !== null) {" & vbCrLf
Script = Script & " playerTime = app.currentTime;" & vbCrLf
Script = Script & " if (playerTime !== null) {" & vbCrLf
Script = Script & " return playerTime;" & vbCrLf
Script = Script & " } else {" & vbCrLf
Script = Script & " return 'null';" & vbCrLf
Script = Script & " }" & vbCrLf
Script = Script & " } else {" & vbCrLf
Script = Script & " return '1';" & vbCrLf
Script = Script & " }" & vbCrLf
Script = Script & "}" & vbCrLf
' connect document
Document.BrowserDispatch (EdgeWebBrowser.Dispatch)
' run the above as anonymous function 2
Document.RunAnonymousFunction 2, Params, Script
End Sub
Private Sub Form_Initialize()
Debug.Print "Form initialize"
Set Document = CreateObject("AntViewAx.AntViewDocument", "")
Document.BrowserDispatch (EdgeWebBrowser.Dispatch)
EdgeWebBrowser.UnlockControl "ExampleCompany", "WI5PO2-2KSU3Q-HWFXFU-IUMU2V-QF8P2F"
End Sub
Private Sub MapLocalFolderToHostName()
Dim Path As String
Dim HostName As String
Path = "C:\testantview\LeadVault"
HostName = "localhost.local"
EdgeWebBrowser.SetVirtualHostNameToFolderMapping HostName, Path, hrakAllow
EdgeWebBrowser.UserDataFolder = Path
End Sub
Private Sub Form_Load()
EdgeWebBrowser.CreateWebView
End Sub
Private Sub Form_Unload(Cancel As Integer)
EdgeWebBrowser.CloseBrowserProcess
EdgeWebBrowser.CloseWebView
End Sub
Private Sub GoButton_Click()
EdgeWebBrowser.Navigate "https://localhost.local/full-player.html"
Debug.Print EdgeWebBrowser.LastErrorCode
End Sub
Private Sub PlayerTimeButton_Click()
readPlayerCurrentTime
End Sub
Pressing the PlayerTimeButton will always return a debugPrint of "1" which makes sense as the object isn't created.
If you can't fix it, then please give me a way to reproduce your problem (aka.. zip your frm/frx in a minimal reproducable case)
--
Wil