Android Question using exoplayer 2nd video no video showing

shb777

Active Member
Licensed User
Longtime User
I'm writing a program to play videos using exoplayer. When the program runs, the screen is mainly black. The first video plays fine. When I stop it before it has finished, it stops, and the screen is mainly gray.
When I then try to play a second video, I can hear the sound, but there is no video.
Here is the relevant code I'm using. I put in a lot of extra code just to try to get it working.
The files i'm playing are on my sd card.

B4X:
Sub Buttonstop_click
    player1.Release
    player1.Initialize("player")
    sources.Clear
    SimpleExoPlayerView1.Invalidate
    SimpleExoPlayerView1.RemoveView
    SimpleExoPlayerView1.Visible=False
    SimpleExoPlayerView1.SendToBack
End Sub


Sub SetSongDirectory  ' set song directory
    
    
    Dim fd As FileDialog
    
    fd.FastScroll = True
    fd.ShowOnlyFolders = False
    fd.FilePath = CurrentDir 'File.DirRootExternal
    ret = fd.Show("B4A File Dialog", "Yes", "No", "Maybe", Bmp)
    
    dir=fd.FilePath
    VideoName=fd.ChosenName
    dir =    fd.FilePath
    Log(fd.FilePath)
    CurrentDir=dir
        
    sources.Add(player1.CreateFileSource(dir, VideoName))
    player1.Initialize("player")
    player1.Prepare(player1.CreateListSource(sources))
    SimpleExoPlayerView1.Visible=True
    SimpleExoPlayerView1.Player = player1
    SimpleExoPlayerView1.ResizeMode = "FIXED_HEIGHT"

    player1.Play
    
End Sub
 
Top