-
- All Implemented Interfaces:
-
com.vdocipher.aegis.player.VdoPlayer
public class CastVdoPlayer implements VdoPlayer
A VdoPlayer implementation that can be used to interact with the VdoCipher Cast receiver app.
In order to use this class, you must pass a CastContext to create an instance.
To track cast session availability, use isCastSessionAvailable to get session status at start, and attach a CastSessionAvailabilityListener using setSessionAvailabilityListener to get further session availability updates.
To join an existing playback session on the receiver app, use joinSession; to load a new session, use load.
-
-
Field Summary
Fields Modifier and Type Field Description public int
playbackState
public boolean
playWhenReady
public MutableLiveData<String>
title
-
Constructor Summary
Constructors Constructor Description CastVdoPlayer(CastContext castContext)
-
Method Summary
Modifier and Type Method Description int
getPlaybackState()
Returns the current state of the player. boolean
getPlayWhenReady()
Whether playback will proceed when getPlaybackState == STATE_READY. void
setPlayWhenReady(boolean playWhenReady)
Sets whether playback should proceed when getPlaybackState == STATE_READY. MutableLiveData<String>
getTitle()
boolean
isCastSessionAvailable()
boolean
joinSession(@NonNull() VdoInitParams vdoParams)
Join an existing cast session if the provided VdoInitParams is being played. boolean
isVideoPlaying()
void
load(VdoInitParams vdoParams)
Immediately starts loading a media for the player to play. void
retry()
Attempt to prepare the media while maintaining its playback state. long
getCurrentTime()
Gets the current playback time of the video from the beginning. long
getBufferedTime()
Gets the time till which video is buffered long
getDuration()
Gets the duration of the current video. boolean
isSpeedControlSupported()
Returns if the current player supports changing the playback speed. void
setPlaybackSpeed(float speed)
Sets the playback speed. float
getPlaybackSpeed()
Returns the currently active playback speed. void
release()
Release system resources used by this VdoPlayer. void
seekTo(long timeInMillis)
Seeks to a particular time in the video. void
addPlaybackEventListener(VdoPlayer.PlaybackEventListener listener)
Register callbacks for playback events from this VdoPlayer void
removePlaybackEventListener(VdoPlayer.PlaybackEventListener listener)
Remove a registered playback event listener from this VdoPlayer void
stop()
Stops the currently loaded video. Array<Track>
getAvailableTracks()
Returns the available tracks for the currently playing media. Array<Track>
getSelectedTracks()
Returns the selected tracks for the currently playing media. void
setSelectedTracks(Array<Track> tracks)
Sets a fixed (non-adaptive) selection of tracks. boolean
isAdaptive()
Returns if the current playback is adaptive. MediaInfo
getCurrentMedia()
Returns a MediaInfo object containing info corresponding to the currently playing media. Object
getPlaybackProperty(String propertyName)
Returns values of additional properties specific to current playback session. void
searchInSelectedSubtitle(String searchText, SubtitleSearchListener subtitleSearchListener)
Search in selected subtitle and seek to matching cues. void
setAutoResumeCallback(AutoResumeCallback autoResumeCallback)
Set callback to provide event when video start resume from saved seek position PlayerOption
getPlayerOptions()
* Called when the player configuration for requested media is loaded. void
updateInternalState()
void
setSessionAvailabilityListener(CastSessionAvailabilityListener listener)
-
-
Method Detail
-
getPlaybackState
int getPlaybackState()
Returns the current state of the player.
-
getPlayWhenReady
boolean getPlayWhenReady()
Whether playback will proceed when getPlaybackState == STATE_READY.
-
setPlayWhenReady
void setPlayWhenReady(boolean playWhenReady)
Sets whether playback should proceed when getPlaybackState == STATE_READY.
If the player is already in the ready state then this method can be used to pause and resume playback.
- Parameters:
playWhenReady
- Whether playback should proceed when ready.
-
getTitle
MutableLiveData<String> getTitle()
-
isCastSessionAvailable
boolean isCastSessionAvailable()
-
joinSession
boolean joinSession(@NonNull() VdoInitParams vdoParams)
Join an existing cast session if the provided VdoInitParams is being played.
-
isVideoPlaying
boolean isVideoPlaying()
-
load
void load(VdoInitParams vdoParams)
Immediately starts loading a media for the player to play.
- Parameters:
vdoParams
- parameters for the playback
-
retry
void retry()
Attempt to prepare the media while maintaining its playback state.
-
getCurrentTime
long getCurrentTime()
Gets the current playback time of the video from the beginning.
-
getBufferedTime
long getBufferedTime()
Gets the time till which video is buffered
-
getDuration
long getDuration()
Gets the duration of the current video.
-
isSpeedControlSupported
boolean isSpeedControlSupported()
Returns if the current player supports changing the playback speed.
-
setPlaybackSpeed
void setPlaybackSpeed(float speed)
Sets the playback speed. Passing 0 or a negative value will reset player to use default playback speed of 1. onPlaybackSpeedChanged will be called when the currently active playback speed changes.
- Parameters:
speed
- factor by which playback speed should be changed
-
getPlaybackSpeed
float getPlaybackSpeed()
Returns the currently active playback speed.
-
release
void release()
Release system resources used by this VdoPlayer.
A new VdoPlayer instance must be created to play/stream another video.
-
seekTo
void seekTo(long timeInMillis)
Seeks to a particular time in the video.
- Parameters:
timeInMillis
- time in milliseconds
-
addPlaybackEventListener
void addPlaybackEventListener(VdoPlayer.PlaybackEventListener listener)
Register callbacks for playback events from this VdoPlayer
- Parameters:
listener
- listener for the callback
-
removePlaybackEventListener
void removePlaybackEventListener(VdoPlayer.PlaybackEventListener listener)
Remove a registered playback event listener from this VdoPlayer
- Parameters:
listener
- the listener to remove
-
stop
void stop()
Stops the currently loaded video.
-
getAvailableTracks
Array<Track> getAvailableTracks()
Returns the available tracks for the currently playing media.
-
getSelectedTracks
Array<Track> getSelectedTracks()
Returns the selected tracks for the currently playing media.
-
setSelectedTracks
void setSelectedTracks(Array<Track> tracks)
Sets a fixed (non-adaptive) selection of tracks. The provided array must contain Track objects returned by the player, and also must contain only single Track corresponding to a Track.TYPE_* constant. Only the first track in the array corresponding to a Track.TYPE_* constant will be acknowledged.
- Parameters:
tracks
- the tracks to select
-
isAdaptive
boolean isAdaptive()
Returns if the current playback is adaptive.
-
getCurrentMedia
MediaInfo getCurrentMedia()
Returns a MediaInfo object containing info corresponding to the currently playing media.
-
getPlaybackProperty
Object getPlaybackProperty(String propertyName)
Returns values of additional properties specific to current playback session. Returned values need to be cast to their expected types before use.
Get the value for propertyName TOTAL_PLAYED, TOTAL_COVERED
- Parameters:
propertyName
- name of desired property
-
searchInSelectedSubtitle
void searchInSelectedSubtitle(String searchText, SubtitleSearchListener subtitleSearchListener)
Search in selected subtitle and seek to matching cues.
- Parameters:
searchText
- text to search in subtitle file.subtitleSearchListener
- SubtitleSearchListener Callback for search result and errors com.vdocipher.aegis.player.internal.subtitle.SubtitleSearchListener.Error.
-
setAutoResumeCallback
void setAutoResumeCallback(AutoResumeCallback autoResumeCallback)
Set callback to provide event when video start resume from saved seek position
- Parameters:
autoResumeCallback
- AutoResumeCallback Callback for autoResumeCallbackcom.vdocipher.aegis.player.internal.util.AutoResumeCallback.
-
getPlayerOptions
PlayerOption getPlayerOptions()
* Called when the player configuration for requested media is loaded.
-
updateInternalState
void updateInternalState()
-
setSessionAvailabilityListener
void setSessionAvailabilityListener(CastSessionAvailabilityListener listener)
-
-
-
-