Package com.castlabs.android.player
Class AbstractPlayerListener
java.lang.Object
com.castlabs.android.player.AbstractPlayerListener
- All Implemented Interfaces:
PlayerListener
- Direct Known Subclasses:
MultiControllerPlaylist
Abstract implementation of the
PlayerListener. All
methods of the the PlayerListener are implemented with empty bodies and you can extend
this class if you only need to implement a subset of the callbacks. Using this abstract class
instead of the interface might also simplify updates of the API.
*NOTE* that all listener methods are invoked on the UI/main thread of your applications.
You can directly interact with UI components from within the implementation of you listener.- Since:
- 1.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for the AbstractPlayerListener. -
Method Summary
Modifier and TypeMethodDescriptionvoidonDisplayChanged(DisplayInfo displayInfo, boolean canPlay) Callback triggered when the underlying screen information changes.voidonDurationChanged(long durationUs) Callback triggered when the stream duration has been refreshed.voidonError(CastlabsPlayerException error) Error callback that is called when exceptions are raised on background threads.voidError callback that is called when a fatal exception is raised on background threads.voidInvoked when all the remaining content has been buffered.voidonPlaybackPositionChanged(long playbackPositionMs) Event triggered when the playback position changed.voidCallback triggered when the player model has been changed and thePlayerControllercan now be queried for available and selected video tracks and qualities, audio tracks and subtitle tracks and the duration.voidThis callback is invoked when the position of the video playback has been changed by thePlayerController.voidonSeekRangeChanged(long startTimeMs, long endTimeMs) Event triggered when the seek range changedvoidonSeekTo(long newPosition) This callback is invoked when the position of the video playback is actively changed by thePlayerController.voidonSpeedChanged(float speed) Callback triggered when the playback speed is changed.voidState change event triggered when the player state changedvoidonVideoKeyStatusChanged(List<VideoTrackQuality> trackList) Callback triggered when video track's DRM-key status is changedvoidonVideoSizeChanged(int width, int height, float pixelWidthHeightRatio) Invoked each time there's a change in the size of the video being rendered.
-
Constructor Details
-
AbstractPlayerListener
public AbstractPlayerListener()Default constructor for the AbstractPlayerListener.
-
-
Method Details
-
onFatalErrorOccurred
Description copied from interface:PlayerListenerError callback that is called when a fatal exception is raised on background threads. All Exceptions are wrapped in aCastlabsPlayerException. This method will be invoked *only* for fatal errors, and *before* the PlayerController isreleased. ThePlayerListener.onError(CastlabsPlayerException)method will be invoked after this one.- Specified by:
onFatalErrorOccurredin interfacePlayerListener- Parameters:
error- the player exception
-
onError
Description copied from interface:PlayerListenerError callback that is called when exceptions are raised on background threads. All Exceptions are wrapped in aCastlabsPlayerException. If the error isfatal, the PlayerController will bereleasedright before this callback.- Specified by:
onErrorin interfacePlayerListener- Parameters:
error- the player exception
-
onStateChanged
Description copied from interface:PlayerListenerState change event triggered when the player state changed- Specified by:
onStateChangedin interfacePlayerListener- Parameters:
state- the new state
-
onSeekTo
public void onSeekTo(long newPosition) Description copied from interface:PlayerListenerThis callback is invoked when the position of the video playback is actively changed by thePlayerController.- Specified by:
onSeekToin interfacePlayerListener- Parameters:
newPosition- the new position in microseconds
-
onSeekCompleted
public void onSeekCompleted()Description copied from interface:PlayerListenerThis callback is invoked when the position of the video playback has been changed by thePlayerController.- Specified by:
onSeekCompletedin interfacePlayerListener- See Also:
-
onVideoSizeChanged
public void onVideoSizeChanged(int width, int height, float pixelWidthHeightRatio) Description copied from interface:PlayerListenerInvoked each time there's a change in the size of the video being rendered.- Specified by:
onVideoSizeChangedin interfacePlayerListener- Parameters:
width- The video width in pixels.height- The video height in pixels.pixelWidthHeightRatio- The width to height ratio of each pixel. For the normal case of square pixels this will be equal to 1.0. Different values are indicative of anamorphic content.
-
onSeekRangeChanged
public void onSeekRangeChanged(long startTimeMs, long endTimeMs) Description copied from interface:PlayerListenerEvent triggered when the seek range changed- Specified by:
onSeekRangeChangedin interfacePlayerListener- Parameters:
startTimeMs- the possible seek start time in millisecondsendTimeMs- the possible seek end time in milliseconds
-
onPlaybackPositionChanged
public void onPlaybackPositionChanged(long playbackPositionMs) Description copied from interface:PlayerListenerEvent triggered when the playback position changed. Note that for performance reasons, this is triggered at most once per second, hence you will only see when seconds changing during playback.- Specified by:
onPlaybackPositionChangedin interfacePlayerListener- Parameters:
playbackPositionMs- the current playback position in milliseconds
-
onDisplayChanged
Description copied from interface:PlayerListenerCallback triggered when the underlying screen information changes. This is triggered for example when a secondary display is connected. The passedcanPlayparameter indicates weather playback can be resumed based on the current display and the secondary display configuration of the player controller (seePlayerController.getSecondaryDisplay()- Specified by:
onDisplayChangedin interfacePlayerListener- Parameters:
displayInfo- the current display informationcanPlay- True if playback can be started or resumed with the current display configuration
-
onDurationChanged
public void onDurationChanged(long durationUs) Description copied from interface:PlayerListenerCallback triggered when the stream duration has been refreshed.- Specified by:
onDurationChangedin interfacePlayerListener- Parameters:
durationUs- Duration in microseconds
-
onSpeedChanged
public void onSpeedChanged(float speed) Description copied from interface:PlayerListenerCallback triggered when the playback speed is changed.- Specified by:
onSpeedChangedin interfacePlayerListener- Parameters:
speed- Playback speed
-
onPlayerModelChanged
public void onPlayerModelChanged()Description copied from interface:PlayerListenerCallback triggered when the player model has been changed and thePlayerControllercan now be queried for available and selected video tracks and qualities, audio tracks and subtitle tracks and the duration. The player model is changed every time upon the playback initial start-up or the media period change. Note that each time the player model changes, the video, audio, subtitle tracks and video quality are re-selected based on the parameters provided inPlayerController.open(android.os.Bundle)or via otherPlayerControllerAPIs. The callback is not triggered when the video, audio, subtitle tracks and video quality are selected by the application during playback usingPlayerController.setVideoTrack(VideoTrack),PlayerController.setVideoQuality(VideoTrackQuality),PlayerController.setAudioTrack(AudioTrack)andPlayerController.setSubtitleTrack(SubtitleTrack).- Specified by:
onPlayerModelChangedin interfacePlayerListener
-
onVideoKeyStatusChanged
Description copied from interface:PlayerListenerCallback triggered when video track's DRM-key status is changed- Specified by:
onVideoKeyStatusChangedin interfacePlayerListener- Parameters:
trackList- The list of tracks with changed key statuses
-
onFullyBuffered
public void onFullyBuffered()Description copied from interface:PlayerListenerInvoked when all the remaining content has been buffered. From this point onwards no more network activity is required to finish playing the current media.- Specified by:
onFullyBufferedin interfacePlayerListener
-