Android Question ExoPlayer stop/pause not working on closing activity

Pravin Shah

Member
Licensed User
Longtime User
Hello,

I have added ExoPlayer in one of the activity to play videos and it is working properly. But when the video is playing and user presses back button, the video still continue to play in background. I want it to be stopped. I tried capturing the back button and tried pausing the video but it is not working. Unless you kill the activity, the video keeps on playing until it is finished. Is it a bug or this is how the library is supposed to work?

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then
        player1.Pause
        player1.Release
        Activity.Finish       
    End If   
End Sub
 

Pravin Shah

Member
Licensed User
Longtime User
I've tried it with this code and it does pause the playback:
B4X:
Sub Activity_Pause (UserClosed As Boolean)
   player1.Pause
End Sub
Thanks Erel for the solution.
Activity_Pause event code works for me as well and also meet my requirements but I am not sure why it it is not working with KeyPress event. Anyways thanks for your help!
 
Upvote 0
Top