B4J Question Webview video pause in a for loop

I display a Webview playing a video, after that a calculation process starts and , inside the calculation I am using a For loop, the video reproduction is affected, I see some pauses, how can I resolve it? I tried with a resumable sub, but the video still pause it. Do I have to create a different theath for the webview?
 
I reduced the problem to the update of the view/UI

B4X:
Sub Temporizador1_Tick    'every second
   
    'Cada Minuto, se actualiza el reloj/fecha/ update the clock in the view date/time every 60 seconds
    duracionReloj = duracionReloj + 1
    If duracionReloj >= 60 Then
        VisorPantalla.ClockView1.ActualizaReloj   
        If socketConectado Then
            ServicioSocket.Ping
        End If
        duracionReloj = 0   
    End If
   
    'Update other elements in the view, here is the problem
    actualizarBannerGrande 
    actualizarBannerChico
    actualizarCartel
    actualizarCarrusel '<-----worse here because it has 6 imagesliders   
   
    'From time to time reset WebView to free resources
    contadorVideos = contadorVideos + 1
    If contadorVideos >= duracionVideos Then
        AdminVideo.destruirWebView = True
        contadorVideos= 0
    End If
       
End Sub


Sub actualizarCarrusel
    If totalUICarrusel >0 Then
        contadorCarrusel = contadorCarrusel + 1
        If contadorCarrusel >= duracionCarrusel Then
            Dim auxCarrusel As AyudaCarrusel
            For i = 0 To totalUICarrusel - 1
                Sleep(0)
                auxCarrusel = vistasCarrusel.Get(i)
                auxCarrusel.Actualizar '<---- Call/update ImageSlider
            Next
            contadorCarrusel = 0
        End If
    End If
End Sub
 
That is my frustration. I prototyped with just the WebView, and after few minutes the video begins to lag, after a few hours is very very very ... slow.
 
OK, I tried and improve it a lot, I will test it for some hours, Thanks you.

To contribute, here my code to center the MediaView (my knowledge of java is zero, so if you find improvements, they are welcome)

B4X:
Private archivo As String = dameArchivo
    If archivo <> Null Then
        tv.Initialize("tv")
        auxiliar.AddNode(tv, xx1, yy1, xx2, yy2)
       
        mp.Initialize("mp",archivo)
       
        mv=jo.InitializeNewInstance("javafx.scene.media.MediaView",Array As Object(mp))
       
        Dim e As Object = mv.CreateEventFromUI("javafx.event.EventHandler","mvError",False)
        mv.RunMethod("setOnError",Array(e))
       
        mv.RunMethod("setPreserveRatio", Array(True)) '<-- to preserve the radio
        mv.RunMethod("setSmooth", Array(True))       
        mv.RunMethod("setFitWidth",Array(anchoPantalla)) 
        mv.RunMethod("setFitHeight",Array(altoPantalla))
       
        pelicula = jopeli.InitializeNewInstance("javafx.scene.layout.BorderPane", Null)
        pelicula.RunMethodJO("setCenter",Array As Object(mv))
        pelicula.RunMethod("setStyle", Array("-fx-border-width : 0 0 0 0"))

        tv.AddNode(pelicula, xx1, yy1, anchoPantalla, altoPantalla)   
       
        Dim auxP As Pane = pelicula
        tv.Top = yy1 - (tv.PrefHeight - auxP.PrefHeight) / 2
       
        mp.Play
    End If
and here my code to free memory from time to time

B4X:
Sub actualizarMediaView
    Dim MediaViewNode As Node = mv
    MediaViewNode.RemoveNodeFromParent
    MediaViewNode = Null
    Dim jo As JavaObject = mp
    jo.RunMethod("dispose", Null)
    tv.RemoveAllNodes
    tv.RemoveNodeFromParent
    tv = Null
End Sub
 
Top