Skip to content

[CastPlayer] Detecting media source ended #4130

Closed

Description

@mkaflowski

How to detect that media has finished for CastPlayer? For Exoplayer there is state STATE_ENDED but CastPlayer goes into STATE_IDLE. The STATE_IDLE occurs when I connect to Chromecast device so I cannot use it as well.

Activity

  1. AquilesCanta commented on Apr 16, 2018

    @AquilesCanta
    Contributor

    Would it be not possible for you to track changes from READY to IDLE? Session state needs to be tracked separately, though.

  2. self-assigned this
    on Apr 16, 2018
  3. mkaflowski commented on Apr 16, 2018

    @mkaflowski
    Author

    The player is READY when I cast, when I stop casting and return to casting it goes to IDLE and then to READY so I would get the recognize it as complete then as well. Is that normal behaviour that it goes to IDLE during connecting to Chromecast or I messed up something?

  4. AquilesCanta commented on Apr 16, 2018

    @AquilesCanta
    Contributor

    Is that normal behaviour that it goes to IDLE during connecting to Chromecast or I messed up something?

    It is normal. This has generated internal discussions, actually. When Cast ends playing a media queue, it empties it. In Player terms, this means the timeline gets emptied. Now, transitioning to ENDED state makes sense. It is documented as follows:

    The player has finished playing the media.

    However, transitioning to IDLE state also makes sense due to the behavior described above:

    The player does not have any media to play.

    This has put on the table the possibility of removing the ended state. For the time being, the discussion is in stand by.

    when I stop casting

    Do you mean the session ends? I don't fully understand your usecase, but tracking the session state + the player state does not solve your issue?

  5. mkaflowski commented on Apr 16, 2018

    @mkaflowski
    Author

    By stoping casting I mean tapping MediaRouteButton and tap the button "Stop Casting". The CastPlayer is in the READY state and when I want to reconnect to Chromecast by tapping MediaRouteButton and selecting device I get IDLE (current state is still READY) and READY then.

    [Edit] The use-case video: Video

  6. deRonbrown commented on Aug 29, 2018

    @deRonbrown

    Would it be possible to make CastPlayer#getMediaStatus() public?

    private @Nullable MediaStatus getMediaStatus() {
      return remoteMediaClient != null ? remoteMediaClient.getMediaStatus() : null;
    }
    

    With that information one could use getIdleReason(). That value would be one of IDLE_REASON_CANCELED, IDLE_REASON_ERROR, IDLE_REASON_FINISHED, IDLE_REASON_INTERRUPTED, or IDLE_REASON_NONE.

  7. deRonbrown commented on Aug 29, 2018

    @deRonbrown

    Actually, no need to make that method public. Just grab the IDLE_REASON directly from the CastSession:

    SessionManager sessionManager = CastContext.getSharedInstance(context).getSessionManager();
    CastSession castSession = sessionManager.getCurrentCastSession();
    if (castSession != null) {
      RemoteMediaClient remoteMediaClient = castSession.getRemoteMediaClient();
      if (remoteMediaClient != null) {
        if (MediaStatus.IDLE_REASON_FINISHED == remoteMediaClient.getIdleReason()) {
          // TODO                            
        }
      }
    }
    
  8. meenukrishnamurthy commented on Mar 4, 2019

    @meenukrishnamurthy

    Any update on this??

  9. ojw28 commented on Sep 14, 2019

    @ojw28
    Contributor

    Marking as a duplicate of #3969

  10. locked and limited conversation to collaborators on Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions