Android Question List videos by folder

Sasuke Sama

Active Member
Licensed User
Hi
Im using the medaiabrowser lib to get a list of the videos on a device but im trying to show them by folders like mx player and any other video players
dose anyone have an idea on where to start?
 

DonManfred

Expert
Licensed User
You can use the File methods to list them by yourself.
You may have a look at the ClassWildcards to get some inspiration.

For external sdcards you need to use the StorageAccessFramework. Note that the Classwildcard does not work on external sdcards.

You need to build your own solution.
 

Sasuke Sama

Active Member
Licensed User
You can use the File methods to list them by yourself.
You may have a look at the ClassWildcards to get some inspiration.

For external sdcards you need to use the StorageAccessFramework. Note that the Classwildcard does not work on external sdcards.

You need to build your own solution.
Dont think its good for my situation
The app is a video player app so i need the mb lib to get not only the video list but the thumb and other stuff
We'll see what other members suggestions
 

Brian Dean

Active Member
Licensed User
I think that I agree with DonManfred. Making a list of files with a known extension is quite straightforward. This code will start from a specified folder [path] and recursively list all the files with a specific entension [extn]. The output is in the list [result].

B4X:
Sub findFiles(path As String, extn As String, result As List)
    Dim files As List = File.ListFiles(path)
    If (files.IsInitialized) Then
        For Each f As String In files
            If (File.IsDirectory(path, f)) Then
                findFiles(path & "/" & f, extn, result)
            Else
                If (f.EndsWith(extn)) Then
                    result.Add(path.Replace(File.DirRootExternal, "") & "/" & f)
                End If
            End If
        Next
    End If
End Sub
You might want to use a list of media file extensions, and you will have to sort out the results list into folder groups, but that is not very difficult and you will have a completely flexible solution.
 
Top