Package com.brightcove.player.playback
Interface MediaPlayback<Player>
- Type Parameters:
Player
- The type of player used for media playback.
- All Known Implementing Classes:
ExoMediaPlayback
,MediaPlayerPlayback
public interface MediaPlayback<Player>
Plays media using the specified player.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the video to the video list at the specified index.void
Adds the video to the end of the video list.void
addAll
(int index, Collection<Video> videos) Inserts all videos in the collection at the specified index.void
addAll
(Collection<Video> videos) Add all videos in the collection to the end of the list.void
clear()
Removes all videos from the list.void
Destroys the current player and releases it from memory.void
emitErrorEvent
(String message) Emits an error event with the message passed in the event's propertiesvoid
emitErrorEvent
(String message, Exception exception) Emits an error event including the message passed and the exception in the propertiesReturns the analytics component, the part of the player that monitors and tracks video playback and engagement.int
Returns the buffer percentageint
Gets the index from the current videolong
Returns the current playhead position of the underlying video player.Get the current source for theVideo
.Get the currently playing video.long
Obtains the playhead position of the "live edge".Get the object which handles showing an on-going player notification.Get the player used for media playback.Returns a immutable copy of the video list.The source selector which uses a delegate to select sources.getVideoAt
(int index) Gets a video from the video list at the specified indexfloat
boolean
hasDvr()
Indicates if the current stream is a live video with DVR.boolean
Returns true if the video is a 360 video otherwise returns falseboolean
Checks the current playhead position with the live edge position and determines if it is within range of the live edge.boolean
isLive()
Indicates whether the current stream is a live video.boolean
boolean
Check if the player is currently playing and the media is audio-only.boolean
Returns if a source has been setvoid
onTaskRemoved
(android.content.Intent rootIntent) This is called when theMediaPlaybackService
is currently running and the user has removed a task that comes from the service's application.void
Prepares the player to play the current video source.void
Creates, configures, and prepares a new instance of MediaPlaybackvoid
remove
(int index) Removes the video at the specified index.default void
Removes and replaces the video at the specified index.void
setCurrentIndex
(int index) Sets the current video to the specified index.void
setProgressInterval
(int progressInterval) Sets the the interval in milliseconds at which to fire PROGRESS events during playback.setVideoPath
(String path) Replaces player content with the video at the specified path.setVideoPath
(String videoPath, Map<String, String> languageCodeCaptionsMap) Replace player content with the video and captions at the specified paths.void
setVideoSource
(Video video, Source source) Sets the video source that will be used for playback.
-
Method Details
-
getPlayer
Player getPlayer()Get the player used for media playback.- Returns:
- The media player.
-
getCurrentVideo
Video getCurrentVideo()Get the currently playing video.- Returns:
- The current media object.
-
getCurrentSource
Source getCurrentSource()Get the current source for theVideo
.- Returns:
- The source used for playback.
-
setVideoSource
Sets the video source that will be used for playback.- Parameters:
video
- reference to the video, if any.source
- reference to the video source, if any.
-
isPlayingAudioOnly
boolean isPlayingAudioOnly()Check if the player is currently playing and the media is audio-only.- Returns:
- True if the player is currently playing audio-only media; false otherwise.
-
getAnalytics
Analytics getAnalytics()Returns the analytics component, the part of the player that monitors and tracks video playback and engagement.- Returns:
- the analytics component
-
getSourceController
DefaultSourceSelectionController getSourceController()The source selector which uses a delegate to select sources.- Returns:
- A source controller
-
onTaskRemoved
void onTaskRemoved(android.content.Intent rootIntent) This is called when theMediaPlaybackService
is currently running and the user has removed a task that comes from the service's application.- Parameters:
rootIntent
- The original Intent that was used to launch the task that is being removed.
-
getNotification
PlaybackNotification getNotification()Get the object which handles showing an on-going player notification.- Returns:
- An object to configure the on-going playback notification.
-
openVideo
Creates, configures, and prepares a new instance of MediaPlayback- Parameters:
video
- reference to the video to be prepared for the playback.source
- reference to the source to played if any.- Throws:
NullPointerException
- if video is null.
-
destroyPlayer
void destroyPlayer()Destroys the current player and releases it from memory. This helps to manage working with the complex state machines that are the MediaPlayer and the SurfaceView- See Also:
-
MediaPlayer
SurfaceView
-
getPlaylist
Returns a immutable copy of the video list. -
isPlaying
boolean isPlaying()- Returns:
- True if the player is currently playing.
-
add
Adds the video to the end of the video list. -
add
Adds the video to the video list at the specified index.- Throws:
IndexOutOfBoundsException
- when index < 0 or index is larger than the size of the video list.
-
addAll
Add all videos in the collection to the end of the list.- Parameters:
videos
- The videos to append.
-
addAll
Inserts all videos in the collection at the specified index.- Throws:
IndexOutOfBoundsException
- when index < 0 or index is larger than the size of the video list.
-
replace
Removes and replaces the video at the specified index.- Parameters:
index
- The index to replace a media item.video
- The video to replace- Throws:
IndexOutOfBoundsException
- when index < 0 or index is larger than the size of the video list.
-
setVideoPath
Replaces player content with the video at the specified path.- Parameters:
path
- HTTP path to a video- Returns:
- The created Video object.
-
setVideoPath
Replace player content with the video and captions at the specified paths.- Parameters:
videoPath
- HTTP path to the videolanguageCodeCaptionsMap
- A map of language code to caption urls.
-
getVideoAt
Gets a video from the video list at the specified index -
getCurrentIndex
int getCurrentIndex()Gets the index from the current video- Returns:
- The index of the current video or -1 if there are none.
-
setCurrentIndex
void setCurrentIndex(int index) Sets the current video to the specified index.- Throws:
IndexOutOfBoundsException
- when index < 0 or index is larger than the size of the video list.
-
remove
void remove(int index) Removes the video at the specified index.- Throws:
IndexOutOfBoundsException
- when index < 0 or index is larger than the size of the video list.
-
clear
void clear()Removes all videos from the list. -
getBufferPercentage
int getBufferPercentage()Returns the buffer percentage -
getVolume
float getVolume() -
isSourceSet
boolean isSourceSet()Returns if a source has been set -
hasDvr
boolean hasDvr()Indicates if the current stream is a live video with DVR.- Returns:
TRUE
iff live video with DVR capabilities is supported.
-
isLive
boolean isLive()Indicates whether the current stream is a live video.- Returns:
TRUE
iff live video is supported.
-
getLiveEdge
long getLiveEdge()Obtains the playhead position of the "live edge".- Returns:
- 0. Subclasses should override to provide a value within three target durations of the maximum position.
-
isInLiveEdge
boolean isInLiveEdge()Checks the current playhead position with the live edge position and determines if it is within range of the live edge.- Returns:
- true if in live edge.
-
getCurrentPosition
long getCurrentPosition()Returns the current playhead position of the underlying video player.If the player has not been set or initialized,
Constants.TIME_UNSET
will returned.- Returns:
- the current playhead position.
-
setProgressInterval
void setProgressInterval(int progressInterval) Sets the the interval in milliseconds at which to fire PROGRESS events during playback. The default is 500ms.- Parameters:
progressInterval
- the PROGRESS interval in milliseconds
-
openCurrentVideoSource
void openCurrentVideoSource()Prepares the player to play the current video source. -
emitErrorEvent
Emits an error event with the message passed in the event's properties -
emitErrorEvent
Emits an error event including the message passed and the exception in the properties -
isCurrentVideo360Mode
boolean isCurrentVideo360Mode()Returns true if the video is a 360 video otherwise returns false
-