Giter Site home page Giter Site logo

Comments (5)

kwonjae-lee avatar kwonjae-lee commented on July 30, 2024

I found this issue when I tried to re-use a view in RecyclerView.
And it looks similar to this issue - #1278

from media.

tonihei avatar tonihei commented on July 30, 2024

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:

  1. 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.
  2. 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.

kwonjae-lee avatar kwonjae-lee commented on July 30, 2024

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.

tonihei avatar tonihei commented on July 30, 2024

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.

kwonjae-lee avatar kwonjae-lee commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.