Class GoogleCastManager

java.lang.Object
com.castlabs.sdk.googlecast.GoogleCastManager

public final class GoogleCastManager extends Object
Utility class that allows to start and control a Google Cast session
Since:
4.0.1
  • Field Details

    • INTENT_STREAM_DURATION

      public static final String INTENT_STREAM_DURATION
      Stream duration. If not informed, MediaInfo.UNKNOWN_DURATION will be sent to the receiver. A long is expected.
      See Also:
    • INTENT_STREAM_LIVE

      public static final String INTENT_STREAM_LIVE
      Stream type. Will send MediaInfo.STREAM_TYPE_LIVE if true, MediaInfo.STREAM_TYPE_BUFFERED if false or MediaInfo.STREAM_TYPE_INVALID if not informed. A boolean is expected.
      See Also:
    • INTENT_SUBTITLES_STYLE

      public static final String INTENT_SUBTITLES_STYLE
      Subtitles style. An instance of SubtitlesStyle is expected.
      See Also:
  • Method Details

    • setCastInfoProvider

      public static void setCastInfoProvider(@Nullable GoogleCastManager.CastInfoProvider provider)
      Sets a GoogleCastManager.CastInfoProvider that will be called before sending the config to the remote cast device. This gives the chance to query and modify any info that is being sent.
      Parameters:
      provider - an instance of GoogleCastManager.CastInfoProvider
    • startCasting

      public static void startCasting(@NonNull PlayerController playerController, @NonNull com.google.android.gms.cast.framework.SessionManager sessionManager, @Nullable com.google.android.gms.cast.MediaMetadata metadata)
      Start casting whatever the provided PlayerController is playing. Playback position, language and subtitles will be transmitted to the cast API. Cast sessions will always start on Adaptive bitrate, regardless of the PlayerController setting.
      Parameters:
      playerController - Where to get the needed info to start casting
      sessionManager - Cast session manager
      metadata - additional metadata to set to the MediaInfo object.
    • startCasting

      public static void startCasting(@Nullable Bundle intentBundle, @NonNull com.google.android.gms.cast.framework.SessionManager sessionManager, @Nullable com.google.android.gms.cast.MediaMetadata metadata)
      Start casting with the configuration provided in a Bundle. This method expects the same Bundle structure as in PlayerController.open(Bundle).
      Parameters:
      intentBundle - Where to get the needed info to start casting
      sessionManager - Cast session manager
      metadata - additional metadata to set to the MediaInfo object.
    • getCurrentPlayerState

      public static RemotePlayerState getCurrentPlayerState(com.google.android.gms.cast.framework.SessionManager sessionManager)

      Provides the current remote player state. This includes the available tracks and the currently selected video quality, audio, and subtitle tracks.

      The object returned by this method is required by the select methods.
      Parameters:
      sessionManager - cast session manager
      Returns:
      a RemotePlayerState instance representing the remote player state
    • selectVideoQuality

      public static void selectVideoQuality(@NonNull com.google.android.gms.cast.framework.SessionManager sessionManager, @NonNull RemotePlayerState playerState, @Nullable VideoTrackQuality videoTrackQuality)
      Select a remote video quality track
      Parameters:
      sessionManager - cast session manager
      playerState - current player state as returned by getCurrentPlayerState(SessionManager)
      videoTrackQuality - desired new video quality track. If null ABR will be used
    • selectAudioTrack

      public static void selectAudioTrack(@NonNull com.google.android.gms.cast.framework.SessionManager sessionManager, @NonNull RemotePlayerState playerState, @NonNull AudioTrack audioTrack)
      Select a remote audio track
      Parameters:
      sessionManager - cast session manager
      playerState - current player state as returned by getCurrentPlayerState(SessionManager)
      audioTrack - desired new audio track
    • selectSubtitleTrack

      public static void selectSubtitleTrack(@NonNull com.google.android.gms.cast.framework.SessionManager sessionManager, @NonNull RemotePlayerState playerState, @Nullable SubtitleTrack subtitleTrack)
      Select a remote subtitle track
      Parameters:
      sessionManager - cast session manager
      playerState - current player state as returned by getCurrentPlayerState(SessionManager)
      subtitleTrack - desired new subtitle track. If null subtitles will be disabled
    • setSubtitleStyle

      public static void setSubtitleStyle(@NonNull com.google.android.gms.cast.framework.SessionManager sessionManager, @NonNull com.castlabs.subtitles.presentation.SubtitlesStyle subtitlesStyle)

      Sets the subtitle style of the remote player.

      If you want to set the font family, you should use setSubtitleStyle(SessionManager, SubtitlesStyle, String) as there's no reliable way to get the font family name from a Typeface object.

      Parameters:
      sessionManager - cast session manager
      subtitlesStyle - desired new subtitle style
    • setSubtitleStyle

      public static void setSubtitleStyle(@NonNull com.google.android.gms.cast.framework.SessionManager sessionManager, @NonNull com.castlabs.subtitles.presentation.SubtitlesStyle subtitlesStyle, @Nullable String fontFamily)
      Sets the subtitle style of the remote player.
      Parameters:
      sessionManager - cast session manager
      subtitlesStyle - desired new subtitle style
      fontFamily - desired font family. If null default family will be used
    • getSubtitleStyle

      @Nullable public static com.castlabs.subtitles.presentation.SubtitlesStyle getSubtitleStyle(@NonNull com.google.android.gms.cast.framework.SessionManager sessionManager)
      Returns the currently set Subtitle style on the RemoteMediaClient
      Parameters:
      sessionManager - cast session manager
      Returns:
      the SubtitlesStyle, or null if it's un-accessible