Android Question ExoPlayer not play local file...

nicieri

Active Member
Licensed User
Longtime User
I can see the video player, but with duration 0, and if I select play in the player control, nothing happens. No message in log

B4X:
Private Sub chooser_Result(Success As Boolean, Dir As String, FileName As String)
    If Success Then
        ProcessFileInfo(FileName, Dir, FileName)
    Else
        Log("File selection was cancelled or failed.")
    End If
End Sub

Sub ProcessFileInfo(uri As String, Dir As String, FileName As String)
    Dim mime As String = GetFileInfoByIndex("mime_type", uri)
    Dim fname As String = GetFileInfoByIndex("_display_name", uri)
    Dim size As String = GetFileInfoByIndex("_size", uri)
    Dim fileExtension As String = fname.SubString(fname.LastIndexOf(".") + 1).ToLowerCase
    Log(mime & " " & fname & " " & size & " " & fileExtension)
    If mime.ToLowerCase.Contains("video") Then
        Log("video")
        ePlayer.Prepare(ePlayer.CreateFileSource(Dir,FileName))   
        ColVideoPlayer1.Player=ePlayer
        ePlayer.Play   
    End If
.
.
.
 

nicieri

Active Member
Licensed User
Longtime User
Solution:


B4X:
        Dim jo As JavaObject
        Dim cd As String = jo.InitializeStatic("anywheresoftware.b4a.objects.streams.File").GetField("ContentDir")
        Dim UriString As String = GetPathFromContentResult(FileName)       
        ePlayer.Prepare(ePlayer.CreateFileSource(cd,UriString))
 
Upvote 0
Top