Search code examples
androidvideoframeworkssurfaceflinger

How to detect if a video is playing on android platform?


Is there some api or method to know if some video is playing on android platform?

I want to stop some background job when a video is playing at foreground.

The api or method had better comes from surfaceflinger, window manager service etc. framework modules.

Thanks.


Solution

  • The SurfaceFlinger process can know that it is receiving frames at a consistent rate, but it can't know if it's a video or just app animation.

    The mediaserver process is responsible for managing the hardware video decoders. It can know if a video is being decoded, but it can't know if the video is being displayed. It won't be involved if the app is using a custom software-only decoder.

    There isn't an unequivocal way to detect that a video is being played and presented on the display.