Package com.castlabs.sdk.googlecast
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGoogleCastManager.CastInfoProviderOptional cast info provider to add or modify request cast params.
-
Field Summary
Fields Modifier and Type Field Description static StringINTENT_STREAM_DURATIONStream duration.static StringINTENT_STREAM_LIVEStream type.static StringINTENT_SUBTITLES_STYLESubtitles style.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RemotePlayerStategetCurrentPlayerState(com.google.android.gms.cast.framework.SessionManager sessionManager)Provides the current remote player state.static SubtitlesStylegetSubtitleStyle(com.google.android.gms.cast.framework.SessionManager sessionManager)Returns the currently set Subtitle style on the RemoteMediaClientstatic voidselectAudioTrack(com.google.android.gms.cast.framework.SessionManager sessionManager, RemotePlayerState playerState, AudioTrack audioTrack)Select a remote audio trackstatic voidselectSubtitleTrack(com.google.android.gms.cast.framework.SessionManager sessionManager, RemotePlayerState playerState, SubtitleTrack subtitleTrack)Select a remote subtitle trackstatic voidselectVideoQuality(com.google.android.gms.cast.framework.SessionManager sessionManager, RemotePlayerState playerState, VideoTrackQuality videoTrackQuality)Select a remote video quality trackstatic voidsetCastInfoProvider(GoogleCastManager.CastInfoProvider provider)Sets aGoogleCastManager.CastInfoProviderthat will be called before sending the config to the remote cast device.static voidsetSubtitleStyle(com.google.android.gms.cast.framework.SessionManager sessionManager, SubtitlesStyle subtitlesStyle)Sets the subtitle style of the remote player.static voidsetSubtitleStyle(com.google.android.gms.cast.framework.SessionManager sessionManager, SubtitlesStyle subtitlesStyle, String fontFamily)Sets the subtitle style of the remote player.static voidstartCasting(Bundle intentBundle, com.google.android.gms.cast.framework.SessionManager sessionManager, com.google.android.gms.cast.MediaMetadata metadata)Start casting with the configuration provided in a Bundle.static voidstartCasting(PlayerController playerController, com.google.android.gms.cast.framework.SessionManager sessionManager, com.google.android.gms.cast.MediaMetadata metadata)Start casting whatever the provided PlayerController is playing.
-
-
-
Field Detail
-
INTENT_STREAM_DURATION
public static final String INTENT_STREAM_DURATION
Stream duration. If not informed,MediaInfo.UNKNOWN_DURATIONwill be sent to the receiver. Alongis expected.- See Also:
- Constant Field Values
-
INTENT_STREAM_LIVE
public static final String INTENT_STREAM_LIVE
Stream type. Will sendMediaInfo.STREAM_TYPE_LIVEiftrue,MediaInfo.STREAM_TYPE_BUFFEREDiffalseorMediaInfo.STREAM_TYPE_INVALIDif not informed. Abooleanis expected.- See Also:
- Constant Field Values
-
INTENT_SUBTITLES_STYLE
public static final String INTENT_SUBTITLES_STYLE
Subtitles style. An instance ofSubtitlesStyleis expected.- See Also:
- Constant Field Values
-
-
Method Detail
-
setCastInfoProvider
public static void setCastInfoProvider(@Nullable GoogleCastManager.CastInfoProvider provider)Sets aGoogleCastManager.CastInfoProviderthat 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 ofGoogleCastManager.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 castingsessionManager- Cast session managermetadata- additional metadata to set to theMediaInfoobject.
-
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 inPlayerController.open(Bundle).- Parameters:
intentBundle- Where to get the needed info to start castingsessionManager- Cast session managermetadata- additional metadata to set to theMediaInfoobject.
-
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 theselectmethods.- 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 managerplayerState- current player state as returned bygetCurrentPlayerState(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 managerplayerState- current player state as returned bygetCurrentPlayerState(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 managerplayerState- current player state as returned bygetCurrentPlayerState(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 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 aTypefaceobject.- Parameters:
sessionManager- cast session managersubtitlesStyle- desired new subtitle style
-
setSubtitleStyle
public static void setSubtitleStyle(@NonNull com.google.android.gms.cast.framework.SessionManager sessionManager, @NonNull SubtitlesStyle subtitlesStyle, @Nullable String fontFamily)Sets the subtitle style of the remote player.- Parameters:
sessionManager- cast session managersubtitlesStyle- desired new subtitle stylefontFamily- desired font family. If null default family will be used
-
getSubtitleStyle
@Nullable public static 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
-
-