Android Question ExoPlayer Plays in background after activity closed

fasilosman

Active Member
Licensed User
Longtime User
Hi all,

I am using SimpleExoplayer to play video from UriSource.

These are the steps.
01. user selects video from Activity 01 and click to play.
02. From Activity 01 CallSubDelayed2 is called to Activity 02 and passed the url to Activity 02.
03. User can stop/play. and close Activity 02, then select another video and plays. This goes on for all videos....

My problem is.
Sometimes (I thing, after playing first video) the audio of old or previous video is playing in background even the activity 02 is closed. I can hear several audios in background.
When I end the app only the audio stops.

B4X:
Sub Globals

    Dim Urls As String

    Dim SimpleExoPlayerView1 As SimpleExoPlayerView
    Dim player1 As SimpleExoPlayer
 

End Sub

Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("viewmlay")


    If FirstTime = False Then ' this code is used when the screen rotates video will be played again

        player1.Initialize("player")
        player1.Prepare(player1.CreateUriSource(Urls))
        SimpleExoPlayerView1.Player = player1
        player1.Play

    End If

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
If player1.IsPlaying Then
    player1.Release
End If
End Sub

Sub Load(mm As Map)

    Urls = mm.Get("url")

    player1.Initialize("player")
    player1.Prepare(player1.CreateUriSource(Urls))
    SimpleExoPlayerView1.Player = player1
    player1.Play
End Sub

Private Sub Player_Error (Message As String)
    Log(Message)
End Sub
Private Sub Player_Complete
    Log("comple")
End Sub
Private Sub Player_Ready
    Log("Ready")
End Sub

Can anyone give me a solution for this.

Thank you.
 
Top