Android Question A sample code for select and play a video file by mediaStore

Solution
B4X:
Sub Button1_Click
    Dim cc As ContentChooser
    cc.Initialize("cc")
    cc.Show("video/*", "choose video")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        player.Prepare(player.CreateUriSource(FileName)) 'ExoPlayer
        player.Play
    End If
End Sub

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Sub Button1_Click
    Dim cc As ContentChooser
    cc.Initialize("cc")
    cc.Show("video/*", "choose video")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        player.Prepare(player.CreateUriSource(FileName)) 'ExoPlayer
        player.Play
    End If
End Sub
 

Attachments

  • CC.zip
    10.2 KB · Views: 339
Upvote 0
Solution

Andris

Active Member
Licensed User
Longtime User
B4X:
Sub Button1_Click
    Dim cc As ContentChooser
    cc.Initialize("cc")
    cc.Show("video/*", "choose video")
    Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
    If Success Then
        player.Prepare(player.CreateUriSource(FileName)) 'ExoPlayer
        player.Play
    End If
End Sub

Erel, the CC folder needs a subfolder named /Shared Files in addition to /B4A in order to compile. Adding CC/Shared Files is all that's needed. Then it compiles OK and choosing video files works perfectly.
 
Last edited:
Upvote 0
Top