Hi, I'm using VideoPlayer in my app, i need to change the speed of my audio file...
I'm trying but nothing works.
I'm trying but nothing works.
B4X:
Private Sub SetPlaybackSpeed(VideoPlayer As VideoPlayer, Speed As Float)
Try
' Accede al objeto nativo asociado al VideoPlayer
Dim no As NativeObject = VideoPlayer
' Obtener el AVPlayerViewController
Dim avPlayerViewController As NativeObject = no.GetField("NativeView") ' Acceso al NativeView
' Verifica si el AVPlayerViewController está inicializado
If avPlayerViewController.IsInitialized = False Or avPlayerViewController = Null Then
Log("No se pudo acceder al AVPlayerViewController (NativeView).")
Return
End If
' Obtener el AVPlayer asociado
Dim avPlayer As NativeObject = avPlayerViewController.GetField("player")
' Verifica si el AVPlayer está inicializado
If avPlayer.IsInitialized = False Or avPlayer = Null Then
Log("No se pudo acceder al AVPlayer (player).")
Return
End If
' Ajustar la velocidad de reproducción
avPlayer.SetField("rate", Speed)
Log("Velocidad configurada correctamente a: " & Speed)
Catch
Log("Error en SetPlaybackSpeed: " & LastException.Message)
End Try
End Sub