Comments (5)
I found this issue when I tried to re-use a view in RecyclerView.
And it looks similar to this issue - #1278
from media.
disable release/initialize player on stop/start the activity (from sample)
First of all, this particular step is not something you should do in a real app because keeping the player (and the codec in particular) while the app is in background may cause unexpected side effects. I understand that you originally reproduced this in RecyclerView, so I appreciate this is just a test setup.
progress of the still screen appears to change in milliseconds
I was not able to reproduce this on my device by using the pause button in the UI, but I think I can reproduce it by calling player.pause()
from within Activity.onStop()
.
The problem may be caused by two different effects:
- The video surface is disconnected and reconnected. When the new surface is connected, it cannot receive any previously decoded frames and will instead receive the next available frame.
- Depending on the timing of the pause operation, you may also see one or two scheduled frame releases that can't be cancelled even during a pause operation. So when you come back, the preview (a kind of screenshot taken by the system when you left) may be slightly different from the one when coming back to it.
from media.
Thanks for your explanation.
And I totally understand your concern( keeping the player (and the codec in particular) while the app is in background may cause unexpected side effects
)
I think, this is not a practical problem, as users typically do not perform the same action repeatedly.
But my service has a requirement which is focused on visibility not on performance.
Because there is flicker of screen when I release and initialize the player.
(The screen is black while the player load media file.)
So isn't this supposed to be fixed? I mean, should I explain to my team member that this is not a problem.
from media.
So isn't this supposed to be fixed?
Could you highlight what exactly you are trying to achieve? There may be alternatives to your current usage pattern.
But generally, the way codecs work is that they release frames to a surface and there is no way to get the last released frame back again. To avoid this, you need to either recreate the codec or not destroy the surface:
- New codec, new (or same) surface -> some initial delay during set up, but can start with the previous frame precisely. This is what the Media3 demo is doing by default.
- Same codec, new surface -> current test setup as described above, can only release the next frame
- Same codec, same surface -> keeps content, but there is no guarantee you can keep the surface. Surfaces are automatically destroyed when the Activity is stopped or they are no longer connected to the view hierarchy. If you handle them in RecyclerView, you may be able to move an existing Surface to an out-of-screen position while you don't need it, or you try
SurfaceControl
to reparent an exiting Surface in another View.
The screen is black while the player load media file
The typical solution to this is to show a placeholder image. You may be able to achieve this by using TextureView
and then call getBitmap
when the surface is destroyed. Or preferably, you can start preparing the output early enough so that it's already ready when it comes into view.
from media.
Thank you, you already suggested alternative solution for me.
Actually I wanted to keep the surface even if it was disconnected from the view hierarchy.
I used "TextureView" and the "TextureView" was destroyed when detached from window (as you mentioned)
I think "SurfaceControl" or "Placeholder image"(from "getBitmap") can be a solution.
from media.
Related Issues (20)
- NetworkTypeObserver makes binding calls on mainthread by default HOT 2
- Getting the decoded from ExoPlayer in advance HOT 6
- Playing a song using MediaSessionService randomly turns on and off bluetooth for some reason on Android 11. HOT 9
- Render subtitles (Cue objects) via an Effect HOT 4
- Current application thread check for player.createMessage HOT 4
- Creating a perpetually loading MediaItem HOT 3
- HttpMediaDrmCallback setKeyRequestProperty PSSH name for header request HOT 1
- Media resumption results in DeadObjectException HOT 2
- Libflac decoder crash: flac_jni.cc (NewStringUTF)
- onVideoSizeChanged should be called before the frame has been written to surface
- How to overlay audio over video and preview in composition Player HOT 1
- DRM Video Playback: Black Screen with Audio Playing HOT 3
- HOWTO: Use DRM with CastPlayer HOT 1
- Android Auto ExoPlayer seeking of the audio track creates error while seeking to the end of the track HOT 1
- How can I play 360 stereoscopic vr video in ExoPlayer HOT 2
- hls+clearkey compatibility
- Unable to play an online stream HOT 1
- Preload Manager intermittent crash when devices is offline HOT 1
- External subtitle with 1.4.0 HOT 1
- CacheWriter cant write cache. ErrnoException open failed: ENOENT HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from media.