Sub Process_Globals
Private xui As XUI
Public stopExibicao As Boolean = False
End Sub
Sub Globals
Private ImageView1 As ImageView
Private WebView1 As WebView
Private Panel1 As Panel
Private SimpleExoPlayerView1 As SimpleExoPlayerView
Private xPlayer As SimpleExoPlayer
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("player")
wait for (ExibirArquivosIndefinidamente) complete (ret As Object)
End Sub
Sub ExibirArquivosIndefinidamente As ResumableSub
Dim pasta As String = File.DirAssets
Dim arquivos As List = File.ListFiles(pasta)
' Never mind about listaFiltrada, it's different in the real code.
' The files are indeed downloaded, but For the sake of example, I placed them internally.
Dim listaFiltrada As List
listaFiltrada.Initialize
For Each nomeArquivo As String In arquivos
If nomeArquivo.Contains("mp4") _
Or nomeArquivo.Contains("txt") _
Or nomeArquivo.Contains("jpg") Then
listaFiltrada.Add(nomeArquivo)
End If
Next
If listaFiltrada.Size = 0 Then
Log("Nenhum arquivo encontrado.")
Return Null
End If
stopExibicao = False ' Reinicia o flag
Dim i As Int = 0
Do While stopExibicao = False
Dim nomeArquivo As String = listaFiltrada.Get(i)
Dim ext As String = nomeArquivo.ToLowerCase
If ext.EndsWith(".jpg") Or ext.EndsWith(".jpeg") Or ext.EndsWith(".png") Then
ImageView1.Bitmap = LoadBitmap(pasta, nomeArquivo)
ImageView1.BringToFront
Sleep(5000) ' Exibe a imagem por 5 segundos
Else If ext.EndsWith(".mp4") Then
xPlayer.Initialize("player")
SimpleExoPlayerView1.Player = xPlayer
xPlayer.Prepare(xPlayer.CreateFileSource(pasta, nomeArquivo))
SimpleExoPlayerView1.BringToFront
xPlayer.Play
Sleep(5000) ' ??? player duration...
Else If ext.EndsWith(".txt") Then
Dim htmlContent As String = File.ReadString(pasta, nomeArquivo)
' Divide o conteúdo em linhas
Dim lines() As String = Regex.Split("\r\n", htmlContent)
Dim extractedURL As String = ""
For Each line As String In lines
If line.StartsWith("URL=") Then
extractedURL = line.SubString(4) ' Remove "URL=" e obtém a URL
Exit
End If
Next
WebView1.LoadUrl("https://" & extractedURL)
WebView1.BringToFront
Sleep(5000) ' Exibe o HTML por 5 segundos
End If
' Incrementa o índice; reinicia ao final da lista
i = i + 1
If i >= listaFiltrada.Size Then
i = 0
End If
Loop
Return Null
End Sub
Private Sub player_Complete
End Sub
Private Sub player_Ready
Log(xPlayer.Duration)
End Sub
Private Sub player_Error (Message As String)
Log(Message)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
stopExibicao = True
End If
Return False
End Sub