Class PlayerController
- Direct Known Subclasses:
SingleControllerPlaylist
PlayerView implementation and its PlayerView.getPlayerController()
method to get the controller instance for the current view.
You can add PlayerListener instances to this controller
to get informed about state changes of the underlying player. All listener methods
are called from within the main thread of your application.- Since:
- 1.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classExperimental features that are not yet stable.static enumRepresents states of the player backend.static @interfaceTypes of tracks. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIdentifies the audio trackstatic final intIdentifies the dts audio renderersContains experimental features that are not yet stable.static final intIdentifies the metadata renderers for HLS ID3 metadatastatic final intIdentifies the subtitle trackstatic final intIdentifies an unknown trackstatic final intIdentifies the video track -
Constructor Summary
ConstructorsConstructorDescriptionPlayerController(Context context) Create a new player controller using the given context -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an audio renderer listenervoidaddCatchupListener(CatchupListener listener) Add a Catchup listenervoidAdd a new event listener to receive custom DASH eventsvoidaddDrmEventListener(DrmEventListener listener) Add aDrmEventListener.voidaddEventMessagesListener(EventMessagesListener eventMessagesListener) Add a new event message listenervoidaddEventStreamListener(EventStreamListener listener) Add a new listener to receive cue-start and cue-end for stream events, corresponding to the event duration.voidAdd a new listener to receive all the events corresponding to the event-streams as a list.voidaddFormatChangeListener(FormatChangeListener listener) Add a new Format change listener.voidaddHttpListener(HttpListener listener) Add a HTTP listenervoidaddLoadControlListener(LoadControlListener listener) Add aLoadControlListener.voidaddMetadataListener(MetadataListener listener) Add a new event listener to receive updates on ID3 Meta-Data tags from HLS streams.voidAdds a listener to receive updates onTimeline.PeriodchangesvoidAdd a new player controller listenervoidaddPlayerListener(PlayerListener listener) Add aPlayerListener.voidAdds aPlayerModelFilter.voidaddRequestModifier(RequestModifier modifier) Add a request modifier.voidAdd aRequestModifier listenervoidaddResponseModifier(ResponseModifier modifier) Add a response modifier.voidAdd a new event listener.voidaddSubtitleTrack(String url, String mimeType, String language, String name) Add a subtitles track to be side-loaded when content is opened.voidaddThumbnailTrack(ThumbnailDataTrack thumbnailDataTrack) Adds a thumbnail track.voidAdds a listener to receive updates onTimelineupdatesvoidaddTimelineListener(TimelineListener listener) Deprecated.voidAdd a new event listener to receive updates related to track selection.voidAdd a video metadata listenervoidAdd a video renderer listenercom.google.android.exoplayer2.source.MediaSourcecreateContentMediaSource(PlayerConfig playerConfig, boolean attachInitialPositionProvider, PlayerPlugin playerPlugin) Creates a MediaSource for just one PlayerConfig.voiddestroy()Call this method when the activity that displays the video player is destroyed.voidDisables the audio focus for the stream regardless of thePlayerConfig.audioAttributesvoidenableTrickplayMode(boolean enable) Enables or disables trickplay playback.Returns the current ABR configurationGets access toAdClientInterfaceAPIsGets access toAdInterfaceAPIsReturns the analytics meta-data associated with the controller.Get the current analytics session if there is one.com.google.android.exoplayer2.audio.AudioAttributesReturns the audio attributes for this player.com.google.android.exoplayer2.AudioFocusCallbackGets the audio focus callback for this player.Returns the current audio track.Returns a list of audio track assets found in the opened movie meta data.longReturns the oldest position that still has buffered content, in microseconds.The bandwidth meter wrapperlongReturns the estimated bandwidth in bits/sec.Returns the buffer configuration of this controllerintReturns an estimate of the percentage in the current content window or ad up to which data is buffered, or 0 if no estimate is available.longReturns an estimate of the position in the current content window or ad up to which data is buffered, in microseconds.intReturn the current buffer size in byteslongReturn the current buffer size ahead of the playhead in media time microsecondsGets theCmcdConfigurationFactorythat will be used to createCmcdConfigurationinstances.<T> TgetComponent(Class<T> type) Returns the player component of the given type if it exists.getComponentView(int viewId) Returns a View previously set throughsetComponentView(int, View)and indexed with a view id.Returns the context associated with this controller.static intgetCurrentPeriodIndexInCurrentWindow(com.google.android.exoplayer2.ExoPlayer player) Get the index of the currentPeriodin the currentWindow.Provides access to theDataSourceFactory.longGet the duration in microseconds of a region of media currently available for playback (including both live and static streams) or -1 if no duration is available for the current stream.Returns the currentHlsClearKeyCacheused for HLS Clearkey requests.Returns a stable identifier for log messages based on this controller instance.static KeyStoreReturns theKeyStorethat will be used to store offline IDs or null if no store is configured.longReturns the remaining license duration for the current DRM session.longReturns the remaining license duration for the current DRM session.Returns the live configuration of this controllerintFor live streams, the number of milliseconds that the playback should lag behind the "live edge" (i.e.longReturns the live edge time in microseconds, orC.TIME_UNSETif unknown or not applicable.longgetLiveEdgeUs(boolean applyOffset) Returns the live edge time in microseconds, orC.TIME_UNSETif unknown or not applicable.longGet the live start time in microseconds since the epoch or -1 if unknown or not applicable.Get the main handler of this controller.intReturn the maximum buffer size in bytescom.google.android.exoplayer2.mediacodec.MediaCodecSelectorReturns theMediaCodecSelector.getModifierDataSourceFactory(int requestType) Provides access to theDataSourceFactorythat will be for the specific request type.Returns the current network configuration of this controller.Gets the local path to the currently played content if it is played offline, otherwisenullgetPath()Returns the path set in this controller or nullcom.google.android.exoplayer2.ExoPlayerAccess the player API instance.Returns the current player configuration.Returns thePlayerListenersthat are used to notify about player events.Gets player's LooperReturns the current player state.Returns the currentIPlayerViewthat is associated with this controller.longGet the position in microseconds which is the playback position within the region of media currently available for playback.longGet the position in microseconds which is the playback position within the period of media currently available for playback.longGets an estimate of the absolute position in microseconds up to which data is buffered.Access the list of currently registered request modifier pluginsAccess the list of currently registered response modifier pluginsintThe secondary display setting, which is a bitmap ofSdkConsts.SECONDARY_DISPLAY_NEVER,SdkConsts.SECONDARY_DISPLAY_ALLOW_UNPROTECTED_CONTENT,SdkConsts.SECONDARY_DISPLAY_ALLOW_SECURE_DISPLAY, andSdkConsts.SECONDARY_DISPLAY_ALLOW_ALWAYS.longGet the end of the current seek range in microseconds orC.TIME_UNSET.floatgetSpeed()Returns the current playback speed.Provides access to previously setSSLSocketFactorycom.castlabs.subtitles.presentation.SubtitlesStyleReturns the current subtitles style settings.Returns the currently active subtitle track.Returns a list of the currently registered subtitles.Returns a list of thumbnail track assets found in the opened DASH manifest.Returns the currentTimeline.Returns the currentTrickplayConfigurationReturns the current video filter configuration.Returns a list of video qualities for the currently active video track.Returns the current displayed video quality.intReturns the current video quality mode.Deprecated.Returns the current video track.Returns a list of video tracks.floatReturns the current output volume (gain) of the audio track.longThe position of the start of the current window relative to the start of the first period belonging to it, in microseconds.booleanReturns whether the player is currently backgrounded.booleanChecks if the current playback is in catch-up mode.booleanReturns true if this controllers filter setting allows HD content playback.booleanisLive()Returns true if the live stream is currently played otherwise falsebooleanReturns true if looping is enables and the player will automatically restart the playback on finish.booleanReturns true if the player is currently playingbooleanReturns true if the player will start playing as soon as it fills enough buffer.booleanReturns true if the player is currently seeking to a new position.static booleanisSupportedAudioCodec(String codec) Checks if the given audio codec is supported.booleanReturns whether the player is currently in trickplay mode or not.voidmovePlayerListeners(PlayerController playerController) Migrates all the listeners from this PlayerController to the given one.voidThis method takes aBundleand extracts the information to create aPlayerConfigfrom the bundle.voidopen(PlayerConfig playerConfig) Opens the given URL to the video.voidOpens the {link PlayerController} with the givenBundlewhich is the saved state obtained withsaveState(Bundle)voidpause()Stop playervoidplay()Start playervoidprepareAnalyticsSession(PlayerConfig playerConfig) Use this method to prepare the analytics session according to the player configuration beforeopen(android.os.Bundle)the player controller.Queries the Key Status for the currently loaded session.queryKeyStatus(TrackRendererPlugin.Type trackType) Queries the Key Status for the currently active session.voidrelease()Release the player instance and reset the underlying player model.voidrelease(boolean preservePlayerResources, boolean preservePlayerViewSurface) Release the player instance and reset the underlying player model.voidreleaseWithException(CastlabsPlayerException exception) Releases the player resources and throws an exception to indicate that the player is in an error state.voidRemove an audio renderer listenervoidremoveCatchupListener(CatchupListener listener) Remove a Catchup listenervoidRemove the given listener.voidremoveDrmEventListener(DrmEventListener listener) Remove a registeredDrmEventListenervoidremoveEventMessagesListener(EventMessagesListener eventMessagesListener) Remove the given listener.voidremoveEventStreamListener(EventStreamListener listener) Remove the given listener.voidRemove the given listener.voidRemove the given listener.voidremoveHttpListener(HttpListener listener) Remove a HTTP listenervoidremoveLoadControlListener(LoadControlListener listener) Remove a registeredLoadControlListenervoidremoveMetadataListener(MetadataListener listener) Remove the given listener.voidRemove the given listener.voidRemove the given listener.voidremovePlayerListener(PlayerListener listener) Remove a registeredPlayerListenervoidRemoves aPlayerModelFilterpreviously added withaddPlayerModelFilter(PlayerModelFilter).voidremoveRequestModifier(RequestModifier modifier) Remove a request modifier.voidRemove a Modifier listenervoidremoveResponseModifier(ResponseModifier modifier) Remove a response modifier.voidRemove the given listener.voidRemove the given listener.voidremoveTimelineListener(TimelineListener listener) Remove the given listener.voidRemove the given listener.voidRemove video metadata listenervoidRemove a video renderer listenervoidResets the audio focus for the stream according to thePlayerConfig.audioAttributesbooleanSaves the state of this controller to the given target bundle.voidscanComponentViews(ViewGroup container) Scans the given ViewGroup for specific PlayerControllerPlugin Views.voidseekWith(long offsetUs) Sets the player to the new position by applying the offset to the current position i.e.voidsetAbrConfiguration(AbrConfiguration abrConfiguration) Set the ABR configuration used by the playervoidsetAnalyticsMetaData(AnalyticsMetaData analyticsMetaData) Set the analytics meta-data.voidsetAnalyticsSession(AnalyticsSession analyticsSession) Set an already existing AnalyticsSession.voidsetAudioFocusCallback(com.google.android.exoplayer2.AudioFocusCallback audioFocusCallback) Sets theAudioFocusCallback.voidsetAudioTrack(AudioTrack track) Sets the current audio track.voidsetBackgrounded(boolean backgrounded) This sends or restores the player from background playback.voidsetBufferConfiguration(BufferConfiguration bufferConfiguration) Set the buffer configuration for this controller.voidsetChangeFramerateStrategy(@com.google.android.exoplayer2.C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy) Sets aC.VideoChangeFrameRateStrategythat will be used by the player when provided with a video outputSurface.voidsetCmcdConfigurationFactory(CmcdConfigurationFactory cmcdConfigurationFactory) Sets theCmcdConfigurationFactorythat will be used to createCmcdConfigurationinstances.voidsetComponentView(int viewId, View view) Set a specific component View.voidsetConfigurationProvider(ConfigurationProvider configurationProvider) Sets the configuration provider e.g.voidsetDataSourceFactory(DataSourceFactory dataSourceFactory) Set theDataSourceFactorythat will be used to create connections.voidsetDisableAnalytics(boolean disableAnalytics) Sets whether analytics should be disabled for the user's session.voidsetExternalSourceSelector(ExternalSourceSelector externalSourceSelector) Set theExternalSourceSelectorthat will be used during CDN fallback Setnullto disable the CDN fallbackvoidsetHdPlaybackEnabled(int filter) Set the HD content filter criteria for this specific controller.voidsetHlsKeyCache(HlsClearKeyCache hlsKeyCache) Sets theHlsClearKeyCacheused for HLS Clearkey requests.voidSets theInitialPositionProvider.voidsetInternalSourceSelectorFactory(com.google.android.exoplayer2.source.dash.manifest.InternalSourceSelector.Factory sourceSelectorFactory) Set theInternalSourceSelector.Factorythat will be used during CDN fallback Setnullto use the defaultPlayerSDK.DEFAULT_INTERNAL_SOURCE_SELECTOR_FACTORYvoidsetLiveConfiguration(LiveConfiguration liveConfiguration) Set the live configuration for this controller.voidsetLoopingEnabled(boolean loopingEnabled) Enable/Disable loopingvoidsetMaxVideoSizeFilter(Point maxVideoSize) voidsetPeriodInfoProvider(PeriodInfoProvider periodInfoProvider) Set thePeriodInfoProviderthat will be used to get additional information for the played period.voidsetPlayerView(IPlayerView playerView) Sets theIPlayerViewinstance that is used to provide the surface and render the video.voidsetPosition(long newPositionUs) Seek the player to the new position in microseconds.voidsetPosition(long newPositionUs, int seekMode) Seek the player to the new position in microseconds using specified seek mode The corresponding event will be sent to analytics session (if any)voidsetPositionInPeriod(long newPositionUs) Seek the player to the new position in microseconds.voidsetSecondaryDisplay(int secondaryDisplay) The secondary display setting, which is a bitmap ofSdkConsts.SECONDARY_DISPLAY_NEVER,SdkConsts.SECONDARY_DISPLAY_ALLOW_UNPROTECTED_CONTENT,SdkConsts.SECONDARY_DISPLAY_ALLOW_SECURE_DISPLAY, andSdkConsts.SECONDARY_DISPLAY_ALLOW_ALWAYS.voidsetSourceSelector(SourceSelector sourceSelector) Deprecated.UsesetExternalSourceSelector(ExternalSourceSelector)} Set theSourceSelectorthat will be used during CDN fallbackvoidsetSpeed(float speed) Enable fast-forward or slow motion playback by specifying the playback speed.voidsetSSLSocketFactory(SSLSocketFactory sslSocketFactory) Set customSSLSocketFactoryto be used in DRM and content requests.voidsetSubtitlesStyle(com.castlabs.subtitles.presentation.SubtitlesStyle subtitlesStyle) Allows you to set the desired captioning style that will be used during subtitle rendering.voidsetSubtitleTrack(SubtitleTrack track) Enables the given subtitle track.voidsetSurface(Surface surface) Set theSurfacethat will be used to render video.booleansetTrickplayConfiguration(TrickplayConfiguration trickplayConfiguration) Sets whichTrickplayConfigurationto use.voidsetVideoFilterConfiguration(VideoFilterConfiguration videoFilter, VideoFilterConfiguration adsFilter) Sets the video filter configuration for both content and ads.voidsetVideoQuality(VideoTrackQuality videoQuality) Set the desired video quality or pass null to enable adaptive bitrate switching (default).voidsetVideoTrack(VideoTrack track) Sets the current video track.voidsetVideoTrack(VideoTrack track, VideoTrackQuality quality) Sets the current video track and a manually selected quality.voidsetVolume(float volume) Sets the output volume (gain) of the audio track.voidunsetComponentView(int viewId) Remove the View linked to the provided view idvoidRemoves all the Component ViewsbooleanQueues a message to an arbitrary target and blocks until its delivered.
-
Field Details
-
UNKNOWN_RENDERER
public static final int UNKNOWN_RENDERERIdentifies an unknown track- See Also:
-
VIDEO_RENDERER
public static final int VIDEO_RENDERERIdentifies the video track- See Also:
-
AUDIO_RENDERER
public static final int AUDIO_RENDERERIdentifies the audio track- See Also:
-
TEXT_RENDERER
public static final int TEXT_RENDERERIdentifies the subtitle track- See Also:
-
METADATA_RENDERER
public static final int METADATA_RENDERERIdentifies the metadata renderers for HLS ID3 metadata- See Also:
-
DTS_RENDERER
public static final int DTS_RENDERERIdentifies the dts audio renderers- See Also:
-
EXPERIMENTAL
Contains experimental features that are not yet stable.
-
-
Constructor Details
-
PlayerController
Create a new player controller using the given context- Parameters:
context- the context
-
-
Method Details
-
getComponent
Returns the player component of the given type if it exists.This method can be called from any thread.
- Type Parameters:
T- The component- Parameters:
type- The target type- Returns:
- The component or null
-
getCmcdConfigurationFactory
Gets theCmcdConfigurationFactorythat will be used to createCmcdConfigurationinstances.This method can be called from any thread.
- Returns:
- The
CmcdConfigurationFactory.
-
setCmcdConfigurationFactory
Sets theCmcdConfigurationFactorythat will be used to createCmcdConfigurationinstances.This method can be called from any thread.
- Parameters:
cmcdConfigurationFactory- TheCmcdConfigurationFactory.
-
setChangeFramerateStrategy
public void setChangeFramerateStrategy(@VideoChangeFrameRateStrategy @com.google.android.exoplayer2.C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy) Sets aC.VideoChangeFrameRateStrategythat will be used by the player when provided with a video outputSurface.The strategy only applies if a
MediaCodec-based videoRendereris enabled. Applications wishing to useSurface.CHANGE_FRAME_RATE_ALWAYSshould set the mode toC.VIDEO_CHANGE_FRAME_RATE_STRATEGY_OFFto disable calls toSurface.setFrameRate(float, int, int)from the player, and should then callSurface.setFrameRate(float, int, int)directly from application code.This method can be called from any thread.
- Parameters:
videoChangeFrameRateStrategy-C.VideoChangeFrameRateStrategy.
-
addPlayerListener
Add aPlayerListener.This method can be called from any thread.
- Parameters:
listener- the listener
-
removePlayerListener
Remove a registeredPlayerListenerThis method can be called from any thread.
- Parameters:
listener- the listener
-
addLoadControlListener
Add aLoadControlListener.This method can be called from any thread.
- Parameters:
listener- the listener
-
removeLoadControlListener
Remove a registeredLoadControlListenerThis method can be called from any thread.
- Parameters:
listener- the listener
-
addDrmEventListener
Add aDrmEventListener.This method can be called from any thread.
- Parameters:
listener- the listener
-
removeDrmEventListener
Remove a registeredDrmEventListenerThis method can be called from any thread.
- Parameters:
listener- the listener
-
addStreamingEventListener
Add a new event listener.This method can be called from any thread.
- Parameters:
listener- the listeners
-
removeStreamingEventListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
addFormatChangeListener
Add a new Format change listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
removeFormatChangeListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
addMetadataListener
Add a new event listener to receive updates on ID3 Meta-Data tags from HLS streams.This method can be called from any thread.
- Parameters:
listener- the listener
-
addCustomDashEventListener
Add a new event listener to receive custom DASH eventsThis method can be called from any thread.
- Parameters:
listener- the listener
-
removeCustomDashEventListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
addEventStreamListener
Add a new listener to receive cue-start and cue-end for stream events, corresponding to the event duration.This method can be called from any thread.
- Parameters:
listener- the listener
-
removeEventStreamListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
addEventStreamListListener
Add a new listener to receive all the events corresponding to the event-streams as a list.This method can be called from any thread.
- Parameters:
listener- the listener
-
removeEventStreamListListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
addTimelineListener
Deprecated.Add a new event listener to receive updates on timeline and period changesThis method can be called from any thread.
- Parameters:
listener- the listener
-
addTimelineChangedListener
Adds a listener to receive updates onTimelineupdatesThis method can be called from any thread.
- Parameters:
listener- the listener
-
addPeriodChangedListener
Adds a listener to receive updates onTimeline.PeriodchangesThis method can be called from any thread.
- Parameters:
listener- the listener
-
addTrackSelectionListener
Add a new event listener to receive updates related to track selection.This method can be called from any thread.
- Parameters:
listener- the listener
-
removeMetadataListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
removeTimelineListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
removeTimelineChangedListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
removePeriodChangedListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
addPlayerControllerListener
Add a new player controller listenerThis method can be called from any thread.
- Parameters:
listener- the listeners
-
removePlayerControllerListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
addEventMessagesListener
Add a new event message listenerThis method can be called from any thread.
- Parameters:
eventMessagesListener- the listener
-
removeEventMessagesListener
Remove the given listener.This method can be called from any thread.
- Parameters:
eventMessagesListener- the listener
-
removeTrackSelectionListener
Remove the given listener.This method can be called from any thread.
- Parameters:
listener- the listener
-
addVideoRendererListener
Add a video renderer listenerThis method can be called from any thread.
- Parameters:
listener- The listener- Since:
- 4.2.4
-
removeVideoRendererListener
Remove a video renderer listenerThis method can be called from any thread.
- Parameters:
listener- The listener- Since:
- 4.2.4
-
addVideoMetadataListener
Add a video metadata listenerThis method can be called from any thread.
- Parameters:
listener- The listener
-
removeVideoMetadataListener
Remove video metadata listenerThis method can be called from any thread.
- Parameters:
listener- The listener
-
addAudioRendererListener
Add an audio renderer listenerThis method can be called from any thread.
- Parameters:
listener- The listener- Since:
- 4.2.25
-
removeAudioRendererListener
Remove an audio renderer listenerThis method can be called from any thread.
- Parameters:
listener- The listener- Since:
- 4.2.25
-
addCatchupListener
Add a Catchup listenerThis method can be called from any thread.
- Parameters:
listener- The listener- Since:
- 4.2.45
-
removeCatchupListener
Remove a Catchup listenerThis method can be called from any thread.
- Parameters:
listener- The listener- Since:
- 4.2.45
-
addHttpListener
Add a HTTP listenerThis method can be called from any thread.
- Parameters:
listener- The listener- Since:
- 4.2.45
-
removeHttpListener
Remove a HTTP listenerThis method can be called from any thread.
- Parameters:
listener- The listener- Since:
- 4.2.45
-
addRequestModifierListener
Add aRequestModifier listenerThis method can be called from any thread.
- Parameters:
listener- The listener- Since:
- 4.2.90
-
removeRequestModifierListener
Remove a Modifier listenerThis method can be called from any thread.
- Parameters:
listener- The listener- Since:
- 4.2.90
-
addRequestModifier
Add a request modifier. Please not that you need to call this before callingopen(Bundle)if you want to modify Manifest requests.This method can be called from any thread.
- Parameters:
modifier- The modifier
-
removeRequestModifier
Remove a request modifier.This method can be called from any thread.
- Parameters:
modifier- The modifier
-
getRequestModifiers
Access the list of currently registered request modifier pluginsThis method can be called from any thread.
- Returns:
- The list of currently registered request modifier plugins
-
addResponseModifier
Add a response modifier.This method can be called from any thread.
- Parameters:
modifier- The modifier- Since:
- 4.2.0
-
removeResponseModifier
Remove a response modifier.This method can be called from any thread.
- Parameters:
modifier- The modifier- Since:
- 4.2.0
-
getResponseModifiers
Access the list of currently registered response modifier pluginsThis method can be called from any thread.
- Returns:
- The list of currently registered response modifier plugins
- Since:
- 4.2.0
-
getSecondaryDisplay
public int getSecondaryDisplay()The secondary display setting, which is a bitmap ofSdkConsts.SECONDARY_DISPLAY_NEVER,SdkConsts.SECONDARY_DISPLAY_ALLOW_UNPROTECTED_CONTENT,SdkConsts.SECONDARY_DISPLAY_ALLOW_SECURE_DISPLAY, andSdkConsts.SECONDARY_DISPLAY_ALLOW_ALWAYS. The setting is initialised toPlayerSDK.SECONDARY_DISPLAYat construction time.This method can be called from any thread.
- Returns:
- The secondary display setting
-
setSecondaryDisplay
public void setSecondaryDisplay(int secondaryDisplay) The secondary display setting, which is a bitmap ofSdkConsts.SECONDARY_DISPLAY_NEVER,SdkConsts.SECONDARY_DISPLAY_ALLOW_UNPROTECTED_CONTENT,SdkConsts.SECONDARY_DISPLAY_ALLOW_SECURE_DISPLAY, andSdkConsts.SECONDARY_DISPLAY_ALLOW_ALWAYS. The setting is initialised toPlayerSDK.SECONDARY_DISPLAYat construction time. This setting is checked when playback is initialized or a display is connected and an error of typeCastlabsPlayerException.TYPE_SECONDARY_DISPLAYwill raised if the setting is not compatible with the current display configuration. The player controller will also register a listener and raise an error when the display configuration changes during playback. As DRM licenses can prevent playback on secondary, insecure, or remote screens. The player will, by default, add a listener to theMediaRoutersystem service in order to process changes in display configurations. It's been observed that, in some specific devices, theMediaRouterservice can't be acquired. In such cases, it's recommended to set this flag toSdkConsts.SECONDARY_DISPLAY_ALLOW_ALWAYS. Note that disabling these screen configuration enforcements might allow playback in circumstances what would otherwise be prevented by the license. If set toSdkConsts.SECONDARY_DISPLAY_ALLOW_ALWAYSand playback is opened, no display configuration checks will take place even if this field is updated afterwards.This method can be called from any thread.
- Parameters:
secondaryDisplay- The secondary display setting
-
getDataSourceFactory
Provides access to theDataSourceFactory. You can use this factory to provide additional header and query parameters that will be send with each request.This method can be called from any thread.
- Returns:
- Returns the instance of the
DataSourceFactory
-
setDataSourceFactory
Set theDataSourceFactorythat will be used to create connections. This factory is responsible to manager request and query parameters, so please make sure that you only set additional parameters after you set any custom data source.This method can be called from any thread.
- Parameters:
dataSourceFactory- the factory instance
-
getSSLSocketFactory
Provides access to previously setSSLSocketFactoryThis method can be called from any thread.
- Returns:
SSLSocketFactoryornullwhen unknown
-
setSSLSocketFactory
Set customSSLSocketFactoryto be used in DRM and content requests. Takes precedence overPlayerSDK.SSL_KEY_STOREThis method can be called from any thread.
- Parameters:
sslSocketFactory-SSLSocketFactory
-
getBandwidthMeterWrapper
The bandwidth meter wrapperThis method can be called from any thread.
- Returns:
- bandwidthMeter
-
setSourceSelector
Deprecated.UsesetExternalSourceSelector(ExternalSourceSelector)} Set theSourceSelectorthat will be used during CDN fallbackThis method can be called from any thread.
- Parameters:
sourceSelector- The CDN selector
-
setExternalSourceSelector
Set theExternalSourceSelectorthat will be used during CDN fallback Setnullto disable the CDN fallbackThis method can be called from any thread.
- Parameters:
externalSourceSelector- The CDN selector
-
setInternalSourceSelectorFactory
public void setInternalSourceSelectorFactory(@Nullable com.google.android.exoplayer2.source.dash.manifest.InternalSourceSelector.Factory sourceSelectorFactory) Set theInternalSourceSelector.Factorythat will be used during CDN fallback Setnullto use the defaultPlayerSDK.DEFAULT_INTERNAL_SOURCE_SELECTOR_FACTORYThis method can be called from any thread.
- Parameters:
sourceSelectorFactory- TheInternalSourceSelector.Factory
-
setConfigurationProvider
Sets the configuration provider e.g. when Widevine license renewal is enabled viaDrmTodayConfiguration.Builder.renewalThreshold(long, TimeUnit)This method can be called from any thread.
- Parameters:
configurationProvider- The configuration provider
-
setPeriodInfoProvider
Set thePeriodInfoProviderthat will be used to get additional information for the played period. Use it to enable period-based ads handling.This method can be called from any thread.
- Parameters:
periodInfoProvider- ThePeriodInfoProvider.PeriodInfoprovider
-
getAdInterface
Gets access toAdInterfaceAPIs- Returns:
AdInterfaceinstance
-
getAdClientInterface
Gets access toAdClientInterfaceAPIs- Returns:
AdClientInterfaceinstance
-
getModifierDataSourceFactory
Provides access to theDataSourceFactorythat will be for the specific request type.This factory wraps around and delegates to the data source factory provided by
getDataSourceFactory().This method can be called from any thread.
- Parameters:
requestType- The request type- Returns:
- Returns the new instance of the
DataSourceFactory
-
setDisableAnalytics
public void setDisableAnalytics(boolean disableAnalytics) Sets whether analytics should be disabled for the user's session.This method can be called from any thread.
- Parameters:
disableAnalytics-trueto disable analytics,falseto enable analytics.
-
isBackgrounded
public boolean isBackgrounded()Returns whether the player is currently backgrounded.This method can be called from any thread.
- Returns:
- True if player is currently playing audio only in the background
-
setBackgrounded
public void setBackgrounded(boolean backgrounded) This sends or restores the player from background playback. If backgrounded, video playback is disabled and the current surface is removed from the player. The visual components can be disposed after this call and audio will continue in the background. If recovering from background, the last video track is re-enabled and the surface is reattached to the player. If you intend to use background playback, please consider using thePlayerServicewhich will handle the background playback session for you. In that case, you will not need to call this method explicitly.- Parameters:
backgrounded- background or restore playback
-
getMainHandler
Get the main handler of this controller.This method can be called from any thread.
- Returns:
- the main handler of this controller
-
getLiveStartTime
public long getLiveStartTime()Get the live start time in microseconds since the epoch or -1 if unknown or not applicable. The live start time is defined as start time of the region of media currently available for playback. The value is updated each time the available region of media is updated. Shall be used for informational purposes only.- Returns:
- liveStartTimeUs the live start time in microseconds if known or -1 otherwise
-
getAudioFocusCallback
public com.google.android.exoplayer2.AudioFocusCallback getAudioFocusCallback()Gets the audio focus callback for this player.This method can be called from any thread.
- Returns:
- the audio focus callback
-
getPlayerLooper
Gets player's LooperThis method can be called from any thread.
- Returns:
- Looper
-
getCurrentPeriodIndexInCurrentWindow
public static int getCurrentPeriodIndexInCurrentWindow(@NonNull com.google.android.exoplayer2.ExoPlayer player) Get the index of the currentPeriodin the currentWindow.- Parameters:
player- The player to get the Period index from.- Returns:
- The current Period index in the current Window, or
C.INDEX_UNSETif the timeline is empty
-
getWindowPositionInFirstPeriod
public long getWindowPositionInFirstPeriod()The position of the start of the current window relative to the start of the first period belonging to it, in microseconds. Shall be used for informational purposes only.- Returns:
- The position of the start of the current window or -1 if unknown or not applicable
-
getPosition
public long getPosition()Get the position in microseconds which is the playback position within the region of media currently available for playback. For live streamsisLive()the current position since epoch can be obtained asgetLiveStartTime()+getPosition()- Returns:
- positionUs the position in microseconds
-
getPositionInPeriod
public long getPositionInPeriod()Get the position in microseconds which is the playback position within the period of media currently available for playback. This value for live streams may be different to whatgetPosition()returns since it is possible (and likely) to have live window smaller than the Period, which usually starts when stream started.- Returns:
- positionUs the position inside the current Period in microseconds
-
setPositionInPeriod
public void setPositionInPeriod(long newPositionUs) Seek the player to the new position in microseconds. The indicated position is interpreted as position in the current Period.The corresponding event will be sent to analytics session (if any)
- Parameters:
newPositionUs- the new position in microseconds for the current Period
-
setPosition
public void setPosition(long newPositionUs) Seek the player to the new position in microseconds. The corresponding event will be sent to analytics session (if any)If the position is
C.TIME_UNSET, will go to the default position of the content.- Parameters:
newPositionUs- the new position in microseconds
-
setPosition
public void setPosition(long newPositionUs, int seekMode) Seek the player to the new position in microseconds using specified seek mode The corresponding event will be sent to analytics session (if any)If the position is
C.TIME_UNSET, will go to the default position of the content.- Parameters:
newPositionUs- the new position in microsecondsseekMode- the seek mode
-
seekWith
public void seekWith(long offsetUs) Sets the player to the new position by applying the offset to the current position i.e. with the negative offset the playback goes backward and with the positive one goes forward. The resulting playback position is clipped with zero and the content duration.- Parameters:
offsetUs- The offset to be applied to the current position
-
setTrickplayConfiguration
Sets whichTrickplayConfigurationto use. Note that in order to apply this configuration you should alsoenableit. -
getTrickplayConfiguration
Returns the currentTrickplayConfigurationThis method can be called from any thread.
- Returns:
- the current TrickplayConfiguration
-
getHlsKeyCache
Returns the currentHlsClearKeyCacheused for HLS Clearkey requests. If no Cache wassetprior to playback open, a new emptyMemoryHlsClearKeyCachecache will be created.This method can be called from any thread.
- Returns:
- the cache
-
setHlsKeyCache
Sets theHlsClearKeyCacheused for HLS Clearkey requests. Must be set before theopen(PlayerConfig)call to take effect.This method can be called from any thread.
- Parameters:
hlsKeyCache- the cache to set
-
isTrickplayMode
public boolean isTrickplayMode()Returns whether the player is currently in trickplay mode or not.This method can be called from any thread.
- Returns:
- whether the player is currently in trickplay mode or not.
-
isCatchingUp
public boolean isCatchingUp()Checks if the current playback is in catch-up mode.This method can be called from any thread.
- Returns:
trueif the playback is in catch-up mode (i.e., catchupTrickplayConfiguration is not null),falseotherwise.
-
enableTrickplayMode
public void enableTrickplayMode(boolean enable) Enables or disables trickplay playback.- Parameters:
enable- enable flag
-
getSpeed
public float getSpeed()Returns the current playback speed.This method can be called from any thread.
- Returns:
- The current playback speed
-
setMaxVideoSizeFilter
Sets the current maximum video size filter, while respecting ABR configuration. Can also be set withSdkConsts.INTENT_VIDEO_SIZE_FILTER. Ifnullwill revert back toPlayerSDK.VIDEO_SIZE_FILTER.This method can be called from any thread.
- Parameters:
maxVideoSize- The current maximum video size filter.
-
setVideoFilterConfiguration
public void setVideoFilterConfiguration(@Nullable VideoFilterConfiguration videoFilter, @Nullable VideoFilterConfiguration adsFilter) Sets the video filter configuration for both content and ads.The video filter configuration determines which video tracks are selected for playback. If
videoFilteris null, it will be set to the default video filter configuration defined byPlayerSDK.VIDEO_FILTER.This method can be called from any thread.
- Parameters:
videoFilter- The video filter configuration for content. Can be null.adsFilter- The video filter configuration for ads. Can be null.
-
addPlayerModelFilter
Adds aPlayerModelFilter. This allows arbitratry track filtering beyond the capabilities of thevideoFilterConfiguration.This method can be called from any thread.
- Parameters:
filter- the filter to add.
-
removePlayerModelFilter
Removes aPlayerModelFilterpreviously added withaddPlayerModelFilter(PlayerModelFilter).This method can be called from any thread.
- Parameters:
filter- the filter to remove.
-
setSpeed
public void setSpeed(float speed) Enable fast-forward or slow motion playback by specifying the playback speed. When the requested speed is different from 1 then the audio is disabled and otherwise is enabled automatically. Note that setting speed for the online playback with high video quality may result in video stuttering/lagging and it is advised to disable the ABR by setting one of the low video qualitiessetVideoQuality(VideoTrackQuality)before changing the playback speed.- Parameters:
speed- The playback speed
-
addSubtitleTrack
public void addSubtitleTrack(@NonNull String url, @NonNull String mimeType, @Nullable String language, @Nullable String name) Add a subtitles track to be side-loaded when content is opened. Note that you will need to call this method before callingopen(PlayerConfig)to successfully add a subtitles track.This method can be called from any thread.
- Parameters:
url- the encoded URL to the subtitles filemimeType- the mime type, i.e text/vtt. This shoudl be one ofSdkConsts.MIME_TYPE_TTML,SdkConsts.MIME_TYPE_VTT,SdkConsts.MIME_TYPE_SRTorSdkConsts.MIME_TYPE_CEA608language- optional two letter language code, i.e. "en"name- optional track nam
-
addThumbnailTrack
Adds a thumbnail track. You should not use this method to sideload thumbnail tracks. To do so, add the thumbnails info in theIntentthat's sent toopen(Bundle)as described inThis method can be called from any thread.
- Parameters:
thumbnailDataTrack- the thumbnail track to add
-
getSubtitleTracks
Returns a list of the currently registered subtitles.This method can be called from any thread.
- Returns:
- A list of the currently registered subtitles
-
getSubtitleTrack
Returns the currently active subtitle track. This can be null if no subtitle track is active.This method can be called from any thread.
- Returns:
- The currently active subtitle track or null if no subtitle track is active
-
setSubtitleTrack
Enables the given subtitle track. You can passnullto disable subtitles- Parameters:
track- the subtitle track or null to disable subtitles
-
setSubtitlesStyle
public void setSubtitlesStyle(@Nullable com.castlabs.subtitles.presentation.SubtitlesStyle subtitlesStyle) Allows you to set the desired captioning style that will be used during subtitle rendering. This will override any styling that is specified by the subtitle content (i.e. TTML with styles) for all style properties where the default setting is explicitly overwritten (see for exampleSubtitlesStyle.hasForegroundColorand the otherhasXXXflags on the style). This method can be used for example, to set the user specified accessibility settings required for FCC compliance. You can passnullto use the default styles specified in the contentThis method can be called from any thread.
- Parameters:
subtitlesStyle- object containing the style settings or null to use default
-
getSubtitlesStyle
@Nullable public com.castlabs.subtitles.presentation.SubtitlesStyle getSubtitlesStyle()Returns the current subtitles style settings.This method can be called from any thread.
- Returns:
- The current subtitles style settings, or
nullif no style is set.
-
getAudioTrack
Returns the current audio track. This can be null if no audio track is available.This method can be called from any thread.
- Returns:
- track the currently selected audio track
-
setAudioTrack
Sets the current audio track. You can passnullto disable audio playback.- Parameters:
track- the audio track
-
getAudioTracks
Returns a list of audio track assets found in the opened movie meta data. *NOTE* that you have to callopen(PlayerConfig)before you can call this method. From 3.0.0, DTS and Dolby tracks are supported via passthrough. This method will return all the audio tracks. It is recommended to test every audio track withAudioTrack.isSupportedCodec()to avoid possible playback issues.This method can be called from any thread.
- Returns:
- audioAssets list of available audio assets
-
getThumbnailTracks
Returns a list of thumbnail track assets found in the opened DASH manifest. *NOTE* that you have to callopen(PlayerConfig)before you can call this method.This method can be called from any thread.
- Returns:
- list of available thumbnails
-
getVideoTrack
Returns the current video track. This can be null if no video track is available.This method can be called from any thread.
- Returns:
- track the currently selected video track
-
setVideoTrack
Sets the current video track. You can passnullto disable video playback. Note that this is not the same assetVideoQuality(VideoTrackQuality)and in most cases you will only have one video track with multiple qualities.- Parameters:
track- the video track
-
setVideoTrack
Sets the current video track and a manually selected quality. You can passnullto disable video playback. Note that this is not the same assetVideoQuality(VideoTrackQuality)and in most cases you will only have one video track with multiple qualities.- Parameters:
track- the video trackquality- the quality
-
getTimeline
Returns the currentTimeline. Can be empty if there's no loaded content.This method can be called from any thread.
- Returns:
- the current
Timeline
-
getVideoTracks
Returns a list of video tracks.This method can be called from any thread.
- Returns:
- videoTracks list of available video tracks or an empty list
-
getVideoQualities
Returns a list of video qualities for the currently active video track.This method can be called from any thread.
- Returns:
- List of
VideoTrackQualitys for the currently active video track in decreasing bitrate order
-
getVideoQuality
Returns the current displayed video quality.This method can be called from any thread.
- Returns:
- The current displayed video quality or
null
-
setVideoQuality
Set the desired video quality or pass null to enable adaptive bitrate switching (default). Note that passing a quality here will disable adaptive bitrate switching and the playback will stay in the given quality. Also, any existinginitial track selectionwill be lost.- Parameters:
videoQuality- the quality
-
getVideoQualityMode
public int getVideoQualityMode()Returns the current video quality mode.This method can be called from any thread.
- Returns:
- The current quality mode. Either
SdkConsts.VIDEO_QUALITY_ADAPTIVEorSdkConsts.VIDEO_QUALITY_MANUAL
-
getAbrConfiguration
Returns the current ABR configurationThis method can be called from any thread.
- Returns:
- The ABR configuration
-
getVideoSizeFilter
Deprecated.Returns the current video size filterThis method can be called from any thread.
- Returns:
- The current video size filter
-
getVideoFilterConfiguration
Returns the current video filter configuration.This method can be called from any thread.
- Returns:
- The current video filter configuration.
-
setAbrConfiguration
Set the ABR configuration used by the playerThis method can be called from any thread.
- Parameters:
abrConfiguration- The Abr configuration or null to reset to the default
-
getMediaCodecSelector
@NonNull public com.google.android.exoplayer2.mediacodec.MediaCodecSelector getMediaCodecSelector()Returns theMediaCodecSelector.This method can be called from any thread.
- Returns:
- the
MediaCodecSelector.
-
getPlayerConfig
Returns the current player configuration.- Returns:
- playerConfig the current playback state or null if no content was loaded yet
- Since:
- 3.0.0
-
getOfflinePath
Gets the local path to the currently played content if it is played offline, otherwisenullThis method can be called from any thread.
- Returns:
- The local path to the offline content or
nullotherwise
-
getPreBufferTime
public long getPreBufferTime()Gets an estimate of the absolute position in microseconds up to which data is buffered.- Returns:
- An estimate of the absolute position in microseconds up to which data is buffered, or 0 if no estimate is available.
-
getBufferSizeBytes
public int getBufferSizeBytes()Return the current buffer size in bytesThis method can be called from any thread.
- Returns:
- The buffer size in bytes
- Since:
- 4.2.6
-
getBufferSizeTime
public long getBufferSizeTime()Return the current buffer size ahead of the playhead in media time microseconds- Returns:
- The buffer size ahead in microseconds
- Since:
- 4.2.6
-
getBufferedPosition
public long getBufferedPosition()Returns an estimate of the position in the current content window or ad up to which data is buffered, in microseconds.- Returns:
- The buffered position in microseconds
- Since:
- 4.2.47
-
getBufferedPercentage
public int getBufferedPercentage()Returns an estimate of the percentage in the current content window or ad up to which data is buffered, or 0 if no estimate is available.This method can be called from any thread.
- Returns:
- The buffered percentage
- Since:
- 4.2.47
-
getMaxBufferSizeBytes
public int getMaxBufferSizeBytes()Return the maximum buffer size in bytesThis method can be called from any thread.
- Returns:
- The max buffer size in bytes
- Since:
- 4.2.5
-
getAudioAttributes
@NonNull public com.google.android.exoplayer2.audio.AudioAttributes getAudioAttributes()Returns the audio attributes for this player.The audio attributes are used by the underlying audio track to determine how to configure the audio sink.
If the player has been released, this method will return
AudioAttributes.DEFAULT.- Returns:
- The audio attributes.
-
getBackBufferTime
public long getBackBufferTime()Returns the oldest position that still has buffered content, in microseconds.If a seek is performed to this position or further, no media should be re-downloaded as it is still present in the buffer.
- Returns:
- the oldest position that still has buffered content, in microseconds.
-
isPlaying
public boolean isPlaying()Returns true if the player is currently playing- Returns:
- true if player is currently playing
-
isSeeking
public boolean isSeeking()Returns true if the player is currently seeking to a new position.This method can be called from any thread.
- Returns:
- true if the player is seeking to a new position after a call to
setPosition(long)
-
isPlayWhenReady
public boolean isPlayWhenReady()Returns true if the player will start playing as soon as it fills enough buffer.This method can be called from any thread.
- Returns:
- true if the player will start playing as soon as it fills enough buffer.
-
getDuration
public long getDuration()Get the duration in microseconds of a region of media currently available for playback (including both live and static streams) or -1 if no duration is available for the current stream. Returns a value < 0 if no duration information at all is available, for example if no content is loaded yet. UseisLive()to check either the content is live or not.- Returns:
- duration duration in microseconds or -1
-
getSeekRangeEndUs
public long getSeekRangeEndUs()Get the end of the current seek range in microseconds orC.TIME_UNSET.- Returns:
- The end of the current seek range in microseconds or
C.TIME_UNSET.
-
getVolume
public float getVolume()Returns the current output volume (gain) of the audio track.This method can be called from any thread.
- Returns:
- The current volume (gain) setting as a value between 0 and 1
-
setVolume
public void setVolume(float volume) Sets the output volume (gain) of the audio track. A value of 0.0 results in zero gain (silence), and a value of 1.0 means unity gain (signal unchanged). The default value is 1.0 meaning unity gain.- Parameters:
volume- the output gain between 0.0 (silence) and 1.0 (signal unchanged)- Throws:
IllegalArgumentException- in case the volume not 0 <= volume <= 1
-
getPath
Returns the path set in this controller or nullThis method can be called from any thread.
- Returns:
- path the path or null
-
getPlayerState
Returns the current player state.This method can be called from any thread.
- Returns:
- the player state
- Since:
- 3.0.0
-
getPlayer
@Nullable public com.google.android.exoplayer2.ExoPlayer getPlayer()Access the player API instance.- Returns:
- player the player instance
-
isLoopingEnabled
public boolean isLoopingEnabled()Returns true if looping is enables and the player will automatically restart the playback on finish.This method can be called from any thread.
- Returns:
- true if looping is enabled
-
setLoopingEnabled
public void setLoopingEnabled(boolean loopingEnabled) Enable/Disable loopingThis method can be called from any thread.
- Parameters:
loopingEnabled- enable or disable looping
-
getAnalyticsSession
Get the current analytics session if there is one. Please note that the session will be initialized only when content was loaded usingopen(Bundle)oropen(PlayerConfig).This method can be called from any thread.
- Returns:
- The analytics session or null
- See Also:
-
setAnalyticsSession
Set an already existing AnalyticsSession. This should be called beforeopen(Bundle). Setting null willdetachthe Session, if any. The caller is responsible to release the session if not reusing.This method can be called from any thread.
- Parameters:
analyticsSession- AnalyticsSession to use in this Player Controller. Should be gotten with thegetAnalyticsSession()before the player controller is disposed. If null, it will unset any Analytics sessions.
-
getAnalyticsMetaData
Returns the analytics meta-data associated with the controller.This method can be called from any thread.
- Returns:
- Get the analytics meta data associated with the controller or null if no data are set
-
setAnalyticsMetaData
Set the analytics meta-data. If you are usingopen(PlayerConfig)and noBundleto start playback, you need to call this method before you start playback to set the required meta-data parameters for the playback session. Without the meta-data object in place, analytics integration will not work since the different analytics integrations require certain mandatory parameters to be set. The documentation and API docs for the different analytics platforms contain information which parameters are mandatory.This method can be called from any thread.
- Parameters:
analyticsMetaData- The meta-data
-
open
This method takes aBundleand extracts the information to create aPlayerConfigfrom the bundle. The following bundle keys are queried to create the playback state: The following keys will be checked:SdkConsts.INTENT_URLexpects a String (mandatory)SdkConsts.INTENT_START_PLAYINGexpects a Boolean (default: true)SdkConsts.INTENT_POSITION_TO_PLAYexpects a Long (default: 0)SdkConsts.INTENT_DRM_CONFIGURATIONexpects aDrmConfiguration(default: null)SdkConsts.INTENT_AUDIO_TRACK_GROUP_IDXexpects aInteger(default: 0 to play the first track)SdkConsts.INTENT_SUBTITLE_TRACK_GROUP_IDXexpects aInteger(default: -1 to disable subtitles)SdkConsts.INTENT_CONTENT_TYPEexpects aInteger(default:SdkConsts.CONTENT_TYPE_UNKNOWNto auto-detect). Allowed values are one ofSdkConsts.CONTENT_TYPE_UNKNOWN,SdkConsts.CONTENT_TYPE_DASH,SdkConsts.CONTENT_TYPE_HLS,SdkConsts.CONTENT_TYPE_SMOOTHSTREAMING, orSdkConsts.CONTENT_TYPE_MP4SdkConsts.INTENT_AUDIO_VOLUMEexpects aFloatwith a value 0 <= value <= 1SdkConsts.INTENT_SECONDARY_DISPLAYexpects aIntegerand defaults to the value ofgetSecondaryDisplay()SdkConsts.INTENT_HD_CONTENT_FILTERexpects aIntegerand defaults to the value ofPlayerSDK.PLAYBACK_HD_CONTENTSdkConsts.INTENT_VIDEO_SIZE_FILTERexpects aPointand defaults to the value ofPlayerSDK.VIDEO_SIZE_FILTERSdkConsts.INTENT_VIDEO_CODEC_FILTERexpects aIntegerand defaults to the value ofPlayerSDK.VIDEO_CODEC_FILTERSdkConsts.INTENT_ENABLE_LOOPINGexpects aBooleanand if true, enables loopingSdkConsts.INTENT_ANALYTICS_DATAexpects aAnalyticsMetaDataobject and is required if you are using one of the analytics pluginsSdkConsts.INTENT_BUFFER_CONFIGURATIONexpects aBufferConfigurationobject and can be used to teak the player bufferSdkConsts.INTENT_ABR_CONFIGURATIONexpects aAbrConfigurationobject and can be used to teak the players ABR behaviourSdkConsts.INTENT_USER_IDexpects aStringSdkConsts.INTENT_LIVE_CONFIGURATIONexpects aLiveConfigurationobject and is used to tweak live-related params
SdkConsts.INTENT_QUERY_PARAMS_BUNDLEandSdkConsts.INTENT_HEADER_PARAMS_BUNDLEto configure and add query and header parameters that will be send with each request. This can for example be used to add tokens when remote resources are requested. In both cases, the bundle needs to reference anotherBundleinstance that is then used as a key/value store for the query or header parameters. You can also useSdkConsts.INTENT_SUBTITLE_BUNDLE_ARRAYLISTto side-load additional subtitle tracks through the bundle. Use the key to store anArrayListofBundleinstances that specify side loaded tracks. Useintent.putParcelableArrayListExtra(SdkConsts.INTENT_SUBTITLE_BUNDLE_ARRAYLIST, ...);to add the list of bundles with the subtitle track information. A full example of this looks like:ArrayList<Bunde> subtitles = new ArrayList<>(); Bundle bundle = new Bundle(); bundle.putString(SdkConsts.INTENT_SUBTITLE_URL, "https://my.com/subtitle.ttml"); bundle.putString(SdkConsts.INTENT_SUBTITLE_MIME_TYPE, SdkConsts.MIME_TYPE_TTML); bundle.putString(SdkConsts.INTENT_SUBTITLE_LANGUAGE, "en"); bundle.putString(SdkConsts.INTENT_SUBTITLE_NAME, "Side-loaded"); subtitles.add(bundle); intent.putExtra(SdkConsts.INTENT_SUBTITLE_BUNDLE_ARRAYLIST, subtitles);- Parameters:
bundle- the bundle- Throws:
IllegalArgumentException- when bundle isnullor does not contain neither a non-emptySdkConsts.INTENT_URLnor non-nullSdkConsts.INTENT_ADVERTS_DATA- Since:
- 3.0.0
- See Also:
-
open
Opens the given URL to the video. You can specify a path to a local file here, but in this case, please note that the path *needs* to be absolute. The path is treated as a URL and a protocol is expected. If no protocol is specified, the `file://` protocol is assumed and prepended to the given path. If you are using an Analytics Plugin, make sure you usesetAnalyticsMetaData(AnalyticsMetaData)to set the required meta-data before calling this method.- Parameters:
playerConfig- the desired Player configuration
-
getIdHashCode
Returns a stable identifier for log messages based on this controller instance.- Returns:
- the identity hash code of this controller as a hexadecimal string
-
prepareAnalyticsSession
Use this method to prepare the analytics session according to the player configuration beforeopen(android.os.Bundle)the player controller.This method can be called from any thread.
- Parameters:
playerConfig- the player configuration
-
play
public void play()Start player -
pause
public void pause()Stop player -
destroy
public void destroy()Call this method when the activity that displays the video player is destroyed. This releases the player the resources allocated by this controller. This call will also remove all callbacks, and in case there's aplayerView, the PlayerController will be removed from it.- Since:
- 1.2.0
-
release
public void release()Release the player instance and reset the underlying player model. You will need to callopen(Bundle)oropen(PlayerConfig)to restart playback. -
release
public void release(boolean preservePlayerResources, boolean preservePlayerViewSurface) Release the player instance and reset the underlying player model. You will need to callopen(Bundle)oropen(PlayerConfig)to restart playback. OverridesPlayerConfig.preservePlayerResourcesandPlayerConfig.preservePlayerViewSurface.- Parameters:
preservePlayerResources- Control if the underlying resources shall be preservedpreservePlayerViewSurface- Control if the player view shall be preserved
-
releaseWithException
Releases the player resources and throws an exception to indicate that the player is in an error state.If
exceptionis null, the player will be released normally.- Parameters:
exception- The exception to throw, or null to release normally.
-
getKeyStore
Returns theKeyStorethat will be used to store offline IDs or null if no store is configured. This is the same asPlayerSDK.DEFAULT_KEY_STORE.This method can be called from any thread.
- Returns:
- The key store or null
-
isHdPlaybackEnabled
public boolean isHdPlaybackEnabled()Returns true if this controllers filter setting allows HD content playback.This method can be called from any thread.
- Returns:
- True if general HD content playback is enabled
-
setHdPlaybackEnabled
public void setHdPlaybackEnabled(int filter) Set the HD content filter criteria for this specific controller. The methods accepts a bit field that is constructed from the values ofSdkConsts.ALLOW_HD_CLEAR_CONTENT,SdkConsts.ALLOW_HD_DRM_SECURE_MEDIA_PATH,SdkConsts.ALLOW_HD_DRM_ROOT_OF_TRUST,SdkConsts.ALLOW_HD_NEVER, andSdkConsts.ALLOW_HD_DRM_SOFTWARE. The default value is the setting forPlayerSDK.PLAYBACK_HD_CONTENT. *This method can be called from any thread.
- Parameters:
filter- The HD content filter setting
-
getBufferConfiguration
Returns the buffer configuration of this controllerThis method can be called from any thread.
- Returns:
- The buffer configuration
-
getLiveConfiguration
Returns the live configuration of this controllerThis method can be called from any thread.
- Returns:
- The Live configuration
-
setBufferConfiguration
Set the buffer configuration for this controller. The buffer configuration can also be changed at runtime.This method can be called from any thread.
- Parameters:
bufferConfiguration- The buffer configuration
-
setLiveConfiguration
Set the live configuration for this controller. You need to call this before you callopen(Bundle)to have an effect on the playback.This method can be called from any thread.
- Parameters:
liveConfiguration- The live configuration
-
setInitialPositionProvider
Sets theInitialPositionProvider.This method can be called from any thread.
- Parameters:
provider- the provider to set
-
getNetworkConfiguration
Returns the current network configuration of this controller.This method can be called from any thread.
- Returns:
- The current network configuration
-
isLive
public boolean isLive()Returns true if the live stream is currently played otherwise false- Returns:
- True if the live stream is currently played otherwise false
-
getLiveEdgeLatency
public int getLiveEdgeLatency()For live streams, the number of milliseconds that the playback should lag behind the "live edge" (i.e. the end of the most recently defined media in the manifest).- Returns:
- liveEdgeLatencyMs The time in milliseconds the player lags behind the live edge
-
openState
Opens the {link PlayerController} with the givenBundlewhich is the saved state obtained withsaveState(Bundle)- Parameters:
bundle- TheBundleto open thePlayerControllerwith
-
saveState
Saves the state of this controller to the given target bundle. This will store the playback state and all intent parameters that are required to restore the state of this controller usingopen(Bundle)with the target bundle. The only exception is the current video quality selection. The video quality will be stored as the initial quality in the bundle if adaptive bitrate switching is turned off and the quality was selected manually. In that case, adaptive bitrate switching will be turned off when the bundle is used to re-open content.- Parameters:
targetBundle- the target bundle- Returns:
- True if the state was saved successfully
-
getContext
Returns the context associated with this controller.This method can be called from any thread.
- Returns:
- the context associated with this controller
-
getPlayerListeners
Returns thePlayerListenersthat are used to notify about player events.This method can be called from any thread.
- Returns:
- the player listeners
-
setSurface
Set theSurfacethat will be used to render video. Note that you usually do not need to call this method explicitly unless you are implementing your ownIPlayerView. You need to call this method when the actual surface is created or destroyed (passnullin that case). Usually you will need to add a listener to the surface provider, i.e.SurfaceView, to be informed about state changes of the underlying surface.- Parameters:
surface- The surface instance or null if the surface was destroyed
-
isSupportedAudioCodec
Checks if the given audio codec is supported.A codec is considered supported if it is not null and not present in the
Codecs.UNSUPPORTED_AUDIO_CODECSlist.This method can be called from any thread.
- Parameters:
codec- The audio codec string to check.- Returns:
trueif the codec is supported or if the input codec isnull,falseotherwise.
-
getLiveEdgeUs
public long getLiveEdgeUs()Returns the live edge time in microseconds, orC.TIME_UNSETif unknown or not applicable. Same asgetLiveEdgeUs()(boolean)} with true param.- Returns:
- the live edge in microseconds.
-
getLiveEdgeUs
public long getLiveEdgeUs(boolean applyOffset) Returns the live edge time in microseconds, orC.TIME_UNSETif unknown or not applicable.- Parameters:
applyOffset- whether the currently set live edge latency (getLiveEdgeLatency()should be taken into account or not.- Returns:
- the live edge in microseconds.
-
setComponentView
Set a specific component View.This method allows to inject Views for some PlayerControllerPlugins to use.
The PlayerControllerPlugins require a specific View to be set. If you are already using a
PlayerView, then the correspondingPlayerViewPluginswill take care of creating and adding these Views.If you opt not to use a PlayerView, you should add through this method the Views you want to provide the
PlayerControllerPluginswith.In case a PlayerControllerPlugin cannot find the expected View it won't create on its own, and won't be able to function properly.
This method can be called from any thread.
- Parameters:
viewId- the viewId which links to the View. This can be usually be found as a constant in thePlayerPluginclass which provides the specific View.view- the instance of the specific View to add.- Since:
- 4.2.2
- See Also:
-
unsetComponentView
public void unsetComponentView(@IdRes int viewId) Remove the View linked to the provided view idThis method can be called from any thread.
- Parameters:
viewId- the view id for the View to remove.- Since:
- 4.2.2
-
unsetComponentViews
public void unsetComponentViews()Removes all the Component ViewsThis method can be called from any thread.
- Since:
- 4.2.2
-
scanComponentViews
Scans the given ViewGroup for specific PlayerControllerPlugin Views.Each
PlayerControllerPluginwill be given the chance to search for its Views in the provided container.The Views can be at any hierarchy level, since they're looked for through the
View.findViewById(int)method.The Views *have* to have as
idthe expected id, usually found as a constant in thePlayerPluginclass which provides the specific View.This method can be called from any thread.
- Parameters:
container- the ViewGroup in which to look for specific Plugin Views- Since:
- 4.2.2
-
getComponentView
Returns a View previously set throughsetComponentView(int, View)and indexed with a view id.The component Views returned by this method are the ones that will be used by their respective plugins.
This method can be called from any thread.
- Parameters:
viewId- the view id which identifies this View- Returns:
- the View linked to the provided viewId
- Since:
- 4.2.2
-
queryKeyStatus
Queries the Key Status for the currently active session. Internally, this queries the platform'sMediaDrm. The status is in the form of {name, value} pairs. Since DRM license policies vary by vendor, the specific status field names are determined by each DRM vendor.This method can be called from any thread.
- Parameters:
trackType- the track type for which to query the Key status. One ofTrackRendererPlugin.Type.Audio,TrackRendererPlugin.Type.VideoorTrackRendererPlugin.Type.Other. Other represents both audio and video; it applies when using the same DrmSessionManager to handle both licenses.- Returns:
- a Map of {name, value} pairs with the status of the currently loaded session, or null if no session is loaded, or the provided trackType does not match with the available DrmSessionManagers.
-
queryKeyStatus
Queries the Key Status for the currently loaded session. Internally, this queries the platform'sMediaDrm. The status is in the form of {name, value} pairs. Since DRM license policies vary by vendor, the specific status field names are determined by each DRM vendor. This method will return the key status for a track with the following priority:TrackRendererPlugin.Type.Other(both Audio and Video)TrackRendererPlugin.Type.VideoTrackRendererPlugin.Type.Audio
This method can be called from any thread.
- Returns:
- a Map of {name, value} pairs with the status of the currently loaded session, or null if no session is loaded.
-
getLicenseRemainingDurationSec
Returns the remaining license duration for the current DRM session. In seconds. ReturnsC.TIME_UNSETif unknown or no DRM session is currently open. If the license has no play duration and no expiration,Long.MAX_VALUEwill be returned.This method can be called from any thread.
- Parameters:
trackType- the track type for which to query the Key status. One ofTrackRendererPlugin.Type.Audio,TrackRendererPlugin.Type.VideoorTrackRendererPlugin.Type.Other. Other represents both audio and video; it applies when using the same DrmSessionManager to handle both licenses.- Returns:
- the remaining license duration in seconds, or C.TIME_UNSET.
-
getLicenseRemainingDurationSec
public long getLicenseRemainingDurationSec()Returns the remaining license duration for the current DRM session. In seconds. ReturnsC.TIME_UNSETif unknown or no DRM session is currently open. If the license has no play duration and no expiration,Long.MAX_VALUEwill be returned. This method will return the remaining license duration for a track with the following priority:TrackRendererPlugin.Type.Other(both Audio and Video)TrackRendererPlugin.Type.VideoTrackRendererPlugin.Type.Audio
This method can be called from any thread.
- Returns:
- the remaining license duration in seconds, or C.TIME_UNSET.
-
disableAudioFocus
public void disableAudioFocus()Disables the audio focus for the stream regardless of thePlayerConfig.audioAttributes -
resetAudioFocus
public void resetAudioFocus()Resets the audio focus for the stream according to thePlayerConfig.audioAttributes -
setPlayerView
Sets theIPlayerViewinstance that is used to provide the surface and render the video. Note that you usually do not need to call this method explicitly unless you are implementing your ownIPlayerView. There is not need to call this method if you are using the defaultPlayerViewimplementation.- Parameters:
playerView- the player view
-
getPlayerView
Returns the currentIPlayerViewthat is associated with this controller.This method can be called from any thread.
- Returns:
- Returns the current view that is associated with this controller or null.
-
setAudioFocusCallback
public void setAudioFocusCallback(@Nullable com.google.android.exoplayer2.AudioFocusCallback audioFocusCallback) Sets theAudioFocusCallback. It will be called when audio focus is lost. It overrides the default behaviour, which is pausing the player.This method can be called from any thread.
- Parameters:
audioFocusCallback- the callback
-
movePlayerListeners
Migrates all the listeners from this PlayerController to the given one. Typical usage of this method is in an implementation ofMultiControllerPlaylist.PlaylistListener.onItemChange(PlayerConfig, PlayerController, PlayerController).This method can be called from any thread.
- Parameters:
playerController- The controller to which the listeners will be moved
-
createContentMediaSource
@NonNull public com.google.android.exoplayer2.source.MediaSource createContentMediaSource(@NonNull PlayerConfig playerConfig, boolean attachInitialPositionProvider, @NonNull PlayerPlugin playerPlugin) Creates a MediaSource for just one PlayerConfig. The resultin MediaSource will be wrapped by aClippingMediaSourceif needed.This method can be called from any thread.
- Parameters:
playerConfig- the config from which to create the MediaSourceattachInitialPositionProvider- whether to attach theInitialPositionProviderto the MediaSourceplayerPlugin- thePlayerPluginthat will create the MediaSource- Returns:
- the MediaSource
-
getBitrateEstimate
public long getBitrateEstimate()Returns the estimated bandwidth in bits/sec.This method can be called from any thread.
- Returns:
- The estimated bandwidth
-
waitForMessages
public boolean waitForMessages()Queues a message to an arbitrary target and blocks until its delivered.- Returns:
- True if the message was delivered
-
addTimelineChangedListener(TimelineChangedListener)oraddPeriodChangedListener(PeriodChangedListener)instead.