Android Question Webview with Vimeo player

juanjo3691

Member
Licensed User
Longtime User
Vimeo player inserted:
Dim nview As Int = 0
            For Each id As Int In listaVideos.Keys
                Dim datos As Map = listaVideos.Get(id)
                Dim videoID As Int = datos.Get("idvideo") ' Cambiar para usar claves del Map
                Dim videoDESCRIPCION As String = datos.Get("descripcion")
                Dim videoREFERENCIA As String = datos.Get("referencia")
                Dim videoPROVEEDOR As String = datos.Get("proveedor")
                Dim embedURL As String = $"https://player.vimeo.com/video/${videoREFERENCIA}?autoplay=0&controls=1&loop=0"$
                Dim vidWebview As WebView
                vidWebview.Initialize($"vidWebview_${nview}"$)
                vidWebview.LoadUrl(embedURL)
                vidWebview.JavaScriptEnabled = True
                svVideosEntrenamiento.Panel.AddView(vidWebview, vidLeft, vidTop, vidWidth, vidHeight)
                svVideosEntrenamiento.Panel.GetView(nview).Background = vidBackground
                vidTop = vidTop + 60%y
                nview = nview + 1
            Next

Hello, i have this code, and it works when try to load the video into the webview, but when i play the video there is a 'V' link, the V from Vimeo that redirect the video to a new url from vimeo web. I try to capture this event but not works. I use JavaScriptEnabled = True, but do not recognize the event click in the V letter.

I tried tu capture the event because i donn't want that de url change and only show the video

Thanks to all
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
i'm not following what the problem is. if i put:
B4X:
Dim videoREFERENCIA As String = "1018833878"
webview.LoadUrl($"https://player.vimeo.com/video/${videoREFERENCE}?autoplay=0&controls=1&loop=0"$)
in an app, i see the attached:
 

Attachments

  • vimeo1.png
    101 KB · Views: 33
  • vimeo2.png
    191 KB · Views: 34
Upvote 0

juanjo3691

Member
Licensed User
Longtime User
Sorry, drgottjr,I haven't explained myself well, if someone clicks on the letter V that represents the Vimeo logo, when you are viewing the video, the webview changes the url and shows another page that is no longer the video.

What I would like is to prevent the webview from leaving the video, but it seems that the click event in the Vimeo player control is not detected.

Thanks for responding!!!
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
site has a CSP in effect. it may be difficult to inject javascript. it will take a lot of trial and error to get it right (unless you're lucky early on). the site's policy appears to leave a few doors open, but you will have to know what you're doing or wait until the collaborative minds of our javascript mavens find the correct statement. "event.preventDefault();" is the usual statement to cause a click on an <a> link to be ignored, but in this case, the CSP doesn't allow you to get that far. i hope this is clear.
 
Last edited:
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
here; this works for me. see if you can work it into your project.
1) load and run the project
2) wait until log says "page loaded"
3) tap "inject" button
4) make sure you see "injection done" in log
5) tap on "V"
6) "V" is blocked
 

Attachments

  • vimeo.zip
    8.2 KB · Views: 19
  • vimeo1.png
    44 KB · Views: 27
  • vimeo2.png
    93.9 KB · Views: 28
  • vimeo3.png
    33.7 KB · Views: 30
Upvote 1
Cookies are required to use this site. You must accept them to continue using the site. Learn more…