-
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
Come up with good solution for attaching/detaching surface from video renderers. #1520
Comments
|
Thanks for the quick reply. That all makes sense. That said, I think most people's instinct will probably be to do the same thing we did initially - expect |
We may well do something to make it more obvious/automatic (probably the latter) in 2.x. Out of interest, what type of media are you playing (DASH/SmoothStreaming/HLS/SomethingElse)? |
Awesome
"Standard" media (H.264 MP4s) |
I also noticed never initializing the videorenderer and just the audiorenderer will trigger the state_ended callback when the activity is paused and the service is running in the background. Tested on a Nexus 6p running 6.0.1. |
@ojw28 how to solve this problem in version 2 ? thank you! |
I'm pretty sure this if fixed in 2.4.0. An enabled MediaCodecVideoTrackRenderer with no surface is now able to consume video, and the ended state should be reported correctly. There are some related issues around seamless switching from no surface to a surface (and from one surface to another) that are largely platform limitations. We'll use #677 to track trying our best to overcome those. |
Great work, great library, thanks for all your hard work.
A description of the issue itself.
This was first discovered when using
ExoPlayer
and backgrounded video (audio continues to play in aService
while theActivity
is paused). We found that on most devices, theonPlaybackStateChange
callback forSTATE_ENDED
was not called when theActivity
was paused, but would fire as soon as theActivity
resumed. On some devices (e.g., HTC One X 4.1.1),STATE_ENDED
happened as expected, even with theActivity
backgrounded/paused.For example:
Activity
that has aTextureView
.Service
that creates anExoPlayer
instance.Service
from theActivity
, setting the surface of theExoPlayer
to theTextureView
. Attach aListener
to theExoPlayer
that logs out state changes.onPlaybackStateChange
callback forSTATE_ENDED
does not fire (on most devices).Activity
(select it from the multi-task / app switcher).onPlaybackStateChange
callback forSTATE_ENDED
will now fire as theActivity
resumes.The cause is:
ExoPlayerImplInternal
callsdoSomeWork
, where it checks if each renderer is "done" by callingisEnded
on each renderer. If all renderers report that they're ended (and meet some other conditions), it firesonPlaybackStateChange
withSTATE_ENDED
.MediaCodecTrackRenderer
'sisEnded
method returnsoutputStreamEnded
, which is apparently not set totrue
in most devices, forMediaCodeVideoTrackRenderer
instances, if there is not a surface to send to. When the surface is replaced, it correctly (and immediately) reportsoutputStreamEnded
/isEnded
to be true, sodoSomeWork
does indeed callonPlaybackStateChange
toSTATE_ENDED
.Steps describing how the issue can be reproduced, ideally in the ExoPlayer demo app.
and a BackgroundAudioService https://gist.github.com/moagrius/f2ca1d2d5c451d8b862304e46caf69f1
null
inVideoPlaybackActivity.onSurfaceTextureDestroyed
onPlaybackStateChange
will fire forSTATE_ENDED
while the Activity is paused.If the issue only reproduces with certain content, a link to some content that we can use to reproduce. If you don’t wish to post a link publicly, please send the link by email to [email protected], including the issue number in the subject line.
n/a
The version of ExoPlayer being used.
1.5.7
The device(s) and version(s) of Android on which the issue can be reproduced, and how easily it reproduces. Does it happen every time, or only occassionally? If possible, please test on multiple devices and Android versions. If the issue does not reproduce on some combinations, that’s useful information!
We've tested on multiple devices, including Nexus 5, Nexus 6, Nexus 7, Samsung Galaxy 6, and HTC One X. So far, only the HTC One X on 4.1.1 did not exhibit the behavior (the video track renderer ended with or without a surface to draw too). It is predictable and reproducible (it never happens on the HTC One X, and always happens on the other devices).
A full bug report taken from the device just after the issue occurs, attached to the issue as a file. A bug report can be captured from the command line using adb bugreport > bugreport.txt. Note that the output from adb logcat or a log snippet is typically not sufficient.
n/a
Anything else you think might be relevant!
The proper way to get around this is to re-use the
SurfaceTexture
, so that it's always available to theMediaCodeVideoTrackRenderer
, even if it's not onscreen, andreturn false
fromonSurfaceTextureDestroyed
so that it is not released. That said, the behavior described above does seem like it could be corrected to behave like I think most users would expect (the audio renderer correctly reported when it had ended, which is when the "media item" as a single entity had concluded - I believe it should have reportedSTATE_ENDED
at that time).Thanks, and let me know if you need any more information.
The text was updated successfully, but these errors were encountered: