-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onPlayerStateChanged is never called when SimpleExoPlayerView is gone. #2432
Comments
I am not certain about this, but usually background applications must make use of service or asynctask so they can continue normal operations while in the background, otherwise most operations are suspended: https://developer.android.com/training/best-background.html Disregard any of this if you are already using any of those methods. |
I have the same issue, I found a thread and I think the accepted answer is: |
Thanks for reply. I found an alternative solution after further investigation.
The problem was that videoRenderer is not ended forever when player goes in background mode. which means "allRenderersEnded" is never set to true. As Contributor mentioned in #1407, I override MediaCodecAudioTrackRenderer.onOutputStreamEnded() and send a message using LocalBroadcastManager to player. It works well! |
Disabling the unused renderers through the TrackSelector should fix your issue. |
As keima mentioned in issue #2461 there is a very noticeable delay when the the renderer is enabled. So when the activity is resumed and the surface is recreated and the renderer is re-enabled the audio playback stops for about 3 seconds. Is there a fix for that? khs8727 could you please provide a more complete example of your solution? |
@khs8727 I face the same problem, could you provide more code of your solution, please ? |
I have a feeling this is fixed in the |
Pretty sure this is fixed in recent V2 releases. Closing. |
Hi,
I'm using ExoPlayer (r2.1.1) to develop a music video application for Android.
I'm a beginner in android development.
I want to play video in background mode as well, so I made "VideoPlayerService" static class for foreground service. It has all variables and methods which handle a video player.
Also I made "VideoPlayerEventListener" which inherits "ExoPlayer.EventListener".
I attach this instance when creating a player like below.
This is the flow to call a video player.
The problem is
When "VideoPlayerViewActivity" is on, "onPlayerStateChanged" works like a charm.
However, "VideoPlayerViewActivity" is off (when application goes background or "VideoPlayerViewActivity" is closed), "onPlayerStateChanged" never called.
I guess that the player instance is still alive in the background because "VideoPlayerService" static class has it as a static variable and video keeps playing even in background. Also I use the player again when "VideoPlayerViewActivity" re-opened (to play video without pausing).
After I research, I found this.
When "SimpleExoPlayerView" on the main screen, the listener works.
However the "SimpleExoPlayerView" is not showing on the main screen, it does not works.
I also checked that "ExoPlayerImpl.handleEvent()" is never called in background.
If my assumption is right,
Why "SimpleExoPlayerView" is related to calling listeners in "SimpleExoPlayer"?
Is possible to play "SimpleExoPlayer" no matter "SimpleExoPlayerView" exist or not?
Any help will be greatly appreciated!
The text was updated successfully, but these errors were encountered: