public class ChromeCastVideoViewAdapter extends java.lang.Object implements StreamAdapter, com.google.android.gms.cast.framework.SessionManagerListener<com.google.android.gms.cast.framework.CastSession>
VideoView
with standard
android api and support for Chromecast. The video can be played locally or casted to a Chromecast device.
Its also possible, to switch between local and remote playback while playing the video.StreamAdapter.Meta
Constructor and Description |
---|
ChromeCastVideoViewAdapter(android.widget.VideoView videoView,
com.google.android.gms.cast.framework.CastContext castContext)
Create the adapter with the given
VideoView and the given CastContext . |
Modifier and Type | Method and Description |
---|---|
int |
getDuration()
Returns the duration by calling the method
VideoView.getDuration() . |
int |
getHeight()
Returns the height of the
VideoView |
StreamAdapter.Meta |
getMeta()
Returns the meta object.
|
int |
getPosition()
Returns the position by calling the method
VideoView.getCurrentPosition() . |
int |
getWidth()
Returns the width of the
VideoView |
boolean |
isCasting()
Returns if video is streaming.
|
void |
onSessionEnded(com.google.android.gms.cast.framework.CastSession session,
int error) |
void |
onSessionEnding(com.google.android.gms.cast.framework.CastSession session) |
void |
onSessionResumed(com.google.android.gms.cast.framework.CastSession session,
boolean wasSuspended) |
void |
onSessionResumeFailed(com.google.android.gms.cast.framework.CastSession session,
int error) |
void |
onSessionResuming(com.google.android.gms.cast.framework.CastSession session,
java.lang.String sessionId) |
void |
onSessionStarted(com.google.android.gms.cast.framework.CastSession session,
java.lang.String sessionId) |
void |
onSessionStartFailed(com.google.android.gms.cast.framework.CastSession session,
int error) |
void |
onSessionStarting(com.google.android.gms.cast.framework.CastSession session) |
void |
onSessionSuspended(com.google.android.gms.cast.framework.CastSession session,
int reason) |
public ChromeCastVideoViewAdapter(android.widget.VideoView videoView, com.google.android.gms.cast.framework.CastContext castContext)
VideoView
and the given CastContext
.videoView
- The video viewcastContext
- The chromecast contextjava.lang.NullPointerException
- If the parameter videoView
or the parameter castContext
is null
.public StreamAdapter.Meta getMeta()
getMeta
in interface StreamAdapter
StreamAdapter.getMeta()
public int getPosition()
VideoView.getCurrentPosition()
.getPosition
in interface StreamAdapter
StreamAdapter.getPosition()
,
VideoView.getCurrentPosition()
public int getDuration()
VideoView.getDuration()
.getDuration
in interface StreamAdapter
StreamAdapter.getDuration()
,
VideoView.getCurrentPosition()
public int getWidth()
VideoView
getWidth
in interface StreamAdapter
View.getWidth()
,
StreamAdapter.getWidth()
public int getHeight()
VideoView
getHeight
in interface StreamAdapter
View.getHeight()
,
StreamAdapter.getHeight()
public boolean isCasting()
isCasting
in interface StreamAdapter
public void onSessionEnded(com.google.android.gms.cast.framework.CastSession session, int error)
onSessionEnded
in interface com.google.android.gms.cast.framework.SessionManagerListener<com.google.android.gms.cast.framework.CastSession>
session
- Session for managing connections to a Cast receiver deviceerror
- Error Codepublic void onSessionResumed(com.google.android.gms.cast.framework.CastSession session, boolean wasSuspended)
onSessionResumed
in interface com.google.android.gms.cast.framework.SessionManagerListener<com.google.android.gms.cast.framework.CastSession>
session
- Session for managing connections to a Cast receiver devicewasSuspended
- Suspend flagpublic void onSessionResumeFailed(com.google.android.gms.cast.framework.CastSession session, int error)
onSessionResumeFailed
in interface com.google.android.gms.cast.framework.SessionManagerListener<com.google.android.gms.cast.framework.CastSession>
session
- Session for managing connections to a Cast receiver deviceerror
- Error Codepublic void onSessionStarted(com.google.android.gms.cast.framework.CastSession session, java.lang.String sessionId)
onSessionStarted
in interface com.google.android.gms.cast.framework.SessionManagerListener<com.google.android.gms.cast.framework.CastSession>
session
- Session for managing connections to a Cast receiver devicesessionId
- Session's Identifierpublic void onSessionStartFailed(com.google.android.gms.cast.framework.CastSession session, int error)
onSessionStartFailed
in interface com.google.android.gms.cast.framework.SessionManagerListener<com.google.android.gms.cast.framework.CastSession>
session
- Session for managing connections to a Cast receiver deviceerror
- Error Codepublic void onSessionStarting(com.google.android.gms.cast.framework.CastSession session)
onSessionStarting
in interface com.google.android.gms.cast.framework.SessionManagerListener<com.google.android.gms.cast.framework.CastSession>
session
- Session for managing connections to a Cast receiver devicepublic void onSessionEnding(com.google.android.gms.cast.framework.CastSession session)
onSessionEnding
in interface com.google.android.gms.cast.framework.SessionManagerListener<com.google.android.gms.cast.framework.CastSession>
session
- Session for managing connections to a Cast receiver devicepublic void onSessionResuming(com.google.android.gms.cast.framework.CastSession session, java.lang.String sessionId)
onSessionResuming
in interface com.google.android.gms.cast.framework.SessionManagerListener<com.google.android.gms.cast.framework.CastSession>
session
- Session for managing connections to a Cast receiver devicesessionId
- Session's Identifierpublic void onSessionSuspended(com.google.android.gms.cast.framework.CastSession session, int reason)
onSessionSuspended
in interface com.google.android.gms.cast.framework.SessionManagerListener<com.google.android.gms.cast.framework.CastSession>
session
- Session for managing connections to a Cast receiver devicereason
- Suspend reason's code