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 interface
GoogleCastManager.CastInfoProvider
Optional cast info provider to add or modify request cast params.
-
Field Summary
Fields Modifier and Type Field Description static String
INTENT_STREAM_DURATION
Stream duration.static String
INTENT_STREAM_LIVE
Stream type.static String
INTENT_SUBTITLES_STYLE
Subtitles style.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RemotePlayerState
getCurrentPlayerState(com.google.android.gms.cast.framework.SessionManager sessionManager)
Provides the current remote player state.static SubtitlesStyle
getSubtitleStyle(com.google.android.gms.cast.framework.SessionManager sessionManager)
Returns the currently set Subtitle style on the RemoteMediaClientstatic void
selectAudioTrack(com.google.android.gms.cast.framework.SessionManager sessionManager, RemotePlayerState playerState, AudioTrack audioTrack)
Select a remote audio trackstatic void
selectSubtitleTrack(com.google.android.gms.cast.framework.SessionManager sessionManager, RemotePlayerState playerState, SubtitleTrack subtitleTrack)
Select a remote subtitle trackstatic void
selectVideoQuality(com.google.android.gms.cast.framework.SessionManager sessionManager, RemotePlayerState playerState, VideoTrackQuality videoTrackQuality)
Select a remote video quality trackstatic void
setCastInfoProvider(GoogleCastManager.CastInfoProvider provider)
Sets aGoogleCastManager.CastInfoProvider
that will be called before sending the config to the remote cast device.static void
setSubtitleStyle(com.google.android.gms.cast.framework.SessionManager sessionManager, SubtitlesStyle subtitlesStyle)
Sets the subtitle style of the remote player.static void
setSubtitleStyle(com.google.android.gms.cast.framework.SessionManager sessionManager, SubtitlesStyle subtitlesStyle, String fontFamily)
Sets the subtitle style of the remote player.static void
startCasting(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 void
startCasting(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_DURATION
will be sent to the receiver. Along
is expected.- See Also:
- Constant Field Values
-
INTENT_STREAM_LIVE
public static final String INTENT_STREAM_LIVE
Stream type. Will sendMediaInfo.STREAM_TYPE_LIVE
iftrue
,MediaInfo.STREAM_TYPE_BUFFERED
iffalse
orMediaInfo.STREAM_TYPE_INVALID
if not informed. Aboolean
is expected.- See Also:
- Constant Field Values
-
INTENT_SUBTITLES_STYLE
public static final String INTENT_SUBTITLES_STYLE
Subtitles style. An instance ofSubtitlesStyle
is expected.- See Also:
- Constant Field Values
-
-
Method Detail
-
setCastInfoProvider
public static void setCastInfoProvider(@Nullable GoogleCastManager.CastInfoProvider provider)
Sets aGoogleCastManager.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 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 theMediaInfo
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 inPlayerController.open(Bundle)
.- Parameters:
intentBundle
- Where to get the needed info to start castingsessionManager
- Cast session managermetadata
- additional metadata to set to theMediaInfo
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 theselect
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 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 aTypeface
object.- 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
-
-