Android Question Opening a video for playing in an external video player (mx player)

Marc De Loose

Member
Licensed User
Longtime User
Hi,

I fairly new here so I am in need of some help.

I am trying to write an app that is able to list some video's and when you select one it should play in an external video player like (mx player pro or the build in player. Does not realy mather)

I was trying to test if it would work and wrote something stupid to try it but I failed. I get an error from mxplayer (or any other player) that it can't play the video. But if i open the app itself it plays so its not the video file that is the problem.

The purpose of the still to write app is that my kid can watch movies on a tablet by clicking a picture that then triggers the movie. It should play in an external app like mxplayer or other videoplayers.
(the movies are stored on an sd card

Here is my test code.

Some help will be greatly appreciated. thx


B4X:
Dim fd As FileDialog
        fd.KeyboardPopUp = False
        fd.FastScroll = True
       
        'fd.FileFilter = "*.*"
        If fd.Show("Selecteer video bestand","Ok","Cancel","",Null) = DialogResponse.POSITIVE Then
            ' load or import the file
            Dim i As Intent
            Dim Vpath = fd.FilePath & fd.ChosenName As String
            Log(Vpath)
            Log(File.DirDefaultExternal)
            i.Initialize(i.ACTION_VIEW,Vpath)
            i.SetType("video/*")
            StartActivity(i)
        End If
 

Marc De Loose

Member
Licensed User
Longtime User
I am a moron... sorry to bother anyones time.

I am putting my own solution here as future reference for anyone who makes the same mistake.

I forgot the forward slash between the path and the filename. :confused:

B4X:
Dim fd As FileDialog
        fd.KeyboardPopUp = False
        fd.FastScroll = True
       
        'fd.FileFilter = "*.*"
        If fd.Show("Selecteer video bestand","Ok","Cancel","",Null) = DialogResponse.POSITIVE Then
            ' load or import the file
            Dim i As Intent
            'Dim Vpath = "file://" & fd.FilePath & "/" & fd.ChosenName As String
            Dim Vpath =  fd.FilePath & "/" & fd.ChosenName As String
       
            Log(Vpath)
            i.Initialize(i.ACTION_VIEW,Vpath)
            i.SetType("video/*")
            StartActivity(i)
        End If
 
Upvote 0
Top