Package com.brightcove.player.playback
Class MediaPlayerPlayback
java.lang.Object
com.brightcove.player.event.AbstractComponent
com.brightcove.player.playback.MediaPlayerPlayback
- All Implemented Interfaces:
Component
,MediaPlayback<android.media.MediaPlayer>
@Emits(events={"bufferedUpdate","completed","didSetSource","didChangeList","didPlay","didInterruptContent","didResumeContent","didPause","didStop","didSeekTo","didSelectSource","error","play","prebufferNextVideo","progress","selectSource","setSource","setVideo","sourceNotPlayable","sourceNotPlayable","videoSizeKnown","videoDurationChanged","willChangeVideo"})
@ListensFor(events={"bufferedUpdate","completed","didPlay","didSetSource","on360FrameAvailable","play","pause","prebufferNextVideo","readyToPlay","stop","seekTo","setSource","setVolume","videoDurationChanged","willChangeVideo","willInterruptContent","willResumeContent"})
@RestrictTo(LIBRARY)
public class MediaPlayerPlayback
extends AbstractComponent
implements MediaPlayback<android.media.MediaPlayer>
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
protected class
-
Field Summary
Modifier and TypeFieldDescriptionboolean
protected Source
protected Video
final android.media.MediaPlayer.OnBufferingUpdateListener
final android.media.MediaPlayer.OnCompletionListener
final android.media.MediaPlayer.OnErrorListener
final android.media.MediaPlayer.OnInfoListener
final android.media.MediaPlayer.OnPreparedListener
final android.media.MediaPlayer.OnSeekCompleteListener
protected int
protected ScheduledFuture<?>
Fields inherited from class com.brightcove.player.event.AbstractComponent
listenerTokens
-
Constructor Summary
ConstructorDescriptionMediaPlayerPlayback
(RenderView renderView, android.content.Context context, EventEmitter eventEmitter) -
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.android.media.MediaPlayer
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 Live with DVR is supported.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 in live edge.boolean
isLive()
Provides a default for handling live videos.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.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.protected void
protected void
Methods inherited from class com.brightcove.player.event.AbstractComponent
addListener, addOnceListener, getEventEmitter, removeListener, removeListeners
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.brightcove.player.playback.MediaPlayback
replace
-
Field Details
-
progressInterval
protected int progressInterval -
updater
-
nextVideo
-
nextSource
-
isPlayingForTesting
public boolean isPlayingForTesting -
onPreparedListener
public final android.media.MediaPlayer.OnPreparedListener onPreparedListener -
onErrorListener
public final android.media.MediaPlayer.OnErrorListener onErrorListener -
onBufferingUpdateListener
public final android.media.MediaPlayer.OnBufferingUpdateListener onBufferingUpdateListener -
onCompletionListener
public final android.media.MediaPlayer.OnCompletionListener onCompletionListener -
onSeekCompleteListener
public final android.media.MediaPlayer.OnSeekCompleteListener onSeekCompleteListener -
onInfoListener
public final android.media.MediaPlayer.OnInfoListener onInfoListener
-
-
Constructor Details
-
MediaPlayerPlayback
public MediaPlayerPlayback(RenderView renderView, android.content.Context context, EventEmitter eventEmitter)
-
-
Method Details
-
openVideo
Description copied from interface:MediaPlayback
Creates, configures, and prepares a new instance of MediaPlayback- Specified by:
openVideo
in interfaceMediaPlayback<android.media.MediaPlayer>
- Parameters:
video
- reference to the video to be prepared for the playback.source
- reference to the source to played if any.
-
openCurrentVideoSource
public void openCurrentVideoSource()Prepares the player to play the current video source.- Specified by:
openCurrentVideoSource
in interfaceMediaPlayback<android.media.MediaPlayer>
-
getSourceController
Description copied from interface:MediaPlayback
The source selector which uses a delegate to select sources.- Specified by:
getSourceController
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- A source controller
-
startUpdater
protected void startUpdater() -
stopUpdater
protected void stopUpdater() -
destroyPlayer
public void destroyPlayer()Destroys the current player and releases it from memory. This seems wasteful, but helps to mitigate working with the complex state machines that are the MediaPlayer and the SurfaceView- Specified by:
destroyPlayer
in interfaceMediaPlayback<android.media.MediaPlayer>
- See Also:
-
MediaPlayer
SurfaceView
-
setVideoSource
Sets the video source that will be used for playback.- Specified by:
setVideoSource
in interfaceMediaPlayback<android.media.MediaPlayer>
- Parameters:
video
- reference to the video, if any.source
- reference to the video source, if any.
-
getPlayer
public android.media.MediaPlayer getPlayer()Description copied from interface:MediaPlayback
Get the player used for media playback.- Specified by:
getPlayer
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- The media player.
-
getCurrentVideo
Description copied from interface:MediaPlayback
Get the currently playing video.- Specified by:
getCurrentVideo
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- The current media object.
-
getCurrentSource
Description copied from interface:MediaPlayback
Get the current source for theVideo
.- Specified by:
getCurrentSource
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- The source used for playback.
-
isPlayingAudioOnly
public boolean isPlayingAudioOnly()Description copied from interface:MediaPlayback
Check if the player is currently playing and the media is audio-only.- Specified by:
isPlayingAudioOnly
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- True if the player is currently playing audio-only media; false otherwise.
-
getAnalytics
Description copied from interface:MediaPlayback
Returns the analytics component, the part of the player that monitors and tracks video playback and engagement.- Specified by:
getAnalytics
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- the analytics component
-
onTaskRemoved
public void onTaskRemoved(android.content.Intent rootIntent) Description copied from interface:MediaPlayback
This is called when theMediaPlaybackService
is currently running and the user has removed a task that comes from the service's application.- Specified by:
onTaskRemoved
in interfaceMediaPlayback<android.media.MediaPlayer>
- Parameters:
rootIntent
- The original Intent that was used to launch the task that is being removed.
-
getNotification
Description copied from interface:MediaPlayback
Get the object which handles showing an on-going player notification.- Specified by:
getNotification
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- An object to configure the on-going playback notification.
-
getPlaylist
Description copied from interface:MediaPlayback
Returns a immutable copy of the video list.- Specified by:
getPlaylist
in interfaceMediaPlayback<android.media.MediaPlayer>
-
isPlaying
public boolean isPlaying()- Specified by:
isPlaying
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- True if the player is currently playing.
-
hasDvr
public boolean hasDvr()Indicates if Live with DVR is supported. Subclasses will override if live with DVR videos are supported.- Specified by:
hasDvr
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
TRUE
iff live video with DVR capabilities is supported.
-
isLive
public boolean isLive()Provides a default for handling live videos. Subclasses will override if live videos are supported.- Specified by:
isLive
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
TRUE
iff live video is supported.
-
getLiveEdge
public long getLiveEdge()Obtains the playhead position of the "live edge".- Specified by:
getLiveEdge
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- 0. Subclasses should override to provide a value within three target durations of the maximum position.
-
isInLiveEdge
public boolean isInLiveEdge()Checks the current playhead position with the live edge position and determines if it is in live edge.- Specified by:
isInLiveEdge
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- true if in live edge.
-
getCurrentPosition
public 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.- Specified by:
getCurrentPosition
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- the current playhead position.
-
setProgressInterval
public void setProgressInterval(int progressInterval) Sets the the interval in milliseconds at which to fire PROGRESS events during playback. The default is 500ms.- Specified by:
setProgressInterval
in interfaceMediaPlayback<android.media.MediaPlayer>
- Parameters:
progressInterval
- the PROGRESS interval in milliseconds
-
add
Description copied from interface:MediaPlayback
Adds the video to the end of the video list.- Specified by:
add
in interfaceMediaPlayback<android.media.MediaPlayer>
-
add
Description copied from interface:MediaPlayback
Adds the video to the video list at the specified index.- Specified by:
add
in interfaceMediaPlayback<android.media.MediaPlayer>
-
addAll
Description copied from interface:MediaPlayback
Add all videos in the collection to the end of the list.- Specified by:
addAll
in interfaceMediaPlayback<android.media.MediaPlayer>
- Parameters:
videos
- The videos to append.
-
addAll
Description copied from interface:MediaPlayback
Inserts all videos in the collection at the specified index.- Specified by:
addAll
in interfaceMediaPlayback<android.media.MediaPlayer>
-
setVideoPath
Description copied from interface:MediaPlayback
Replaces player content with the video at the specified path.- Specified by:
setVideoPath
in interfaceMediaPlayback<android.media.MediaPlayer>
- Parameters:
path
- HTTP path to a video- Returns:
- The created Video object.
-
setVideoPath
Description copied from interface:MediaPlayback
Replace player content with the video and captions at the specified paths.- Specified by:
setVideoPath
in interfaceMediaPlayback<android.media.MediaPlayer>
- Parameters:
videoPath
- HTTP path to the videolanguageCodeCaptionsMap
- A map of language code to caption urls.
-
getVideoAt
Description copied from interface:MediaPlayback
Gets a video from the video list at the specified index- Specified by:
getVideoAt
in interfaceMediaPlayback<android.media.MediaPlayer>
-
getCurrentIndex
public int getCurrentIndex()Description copied from interface:MediaPlayback
Gets the index from the current video- Specified by:
getCurrentIndex
in interfaceMediaPlayback<android.media.MediaPlayer>
- Returns:
- The index of the current video or -1 if there are none.
-
setCurrentIndex
public void setCurrentIndex(int index) Description copied from interface:MediaPlayback
Sets the current video to the specified index.- Specified by:
setCurrentIndex
in interfaceMediaPlayback<android.media.MediaPlayer>
-
remove
Description copied from interface:MediaPlayback
Removes the video at the specified index.- Specified by:
remove
in interfaceMediaPlayback<android.media.MediaPlayer>
- Throws:
IndexOutOfBoundsException
- when index < 0 or index is larger than the size of the video list.
-
clear
public void clear()Description copied from interface:MediaPlayback
Removes all videos from the list.- Specified by:
clear
in interfaceMediaPlayback<android.media.MediaPlayer>
-
getBufferPercentage
public int getBufferPercentage()Description copied from interface:MediaPlayback
Returns the buffer percentage- Specified by:
getBufferPercentage
in interfaceMediaPlayback<android.media.MediaPlayer>
-
getVolume
public float getVolume()- Specified by:
getVolume
in interfaceMediaPlayback<android.media.MediaPlayer>
-
isSourceSet
public boolean isSourceSet()Description copied from interface:MediaPlayback
Returns if a source has been set- Specified by:
isSourceSet
in interfaceMediaPlayback<android.media.MediaPlayer>
-
isCurrentVideo360Mode
public boolean isCurrentVideo360Mode()Description copied from interface:MediaPlayback
Returns true if the video is a 360 video otherwise returns false- Specified by:
isCurrentVideo360Mode
in interfaceMediaPlayback<android.media.MediaPlayer>
-
emitErrorEvent
Description copied from interface:MediaPlayback
Emits an error event with the message passed in the event's properties- Specified by:
emitErrorEvent
in interfaceMediaPlayback<android.media.MediaPlayer>
-
emitErrorEvent
Description copied from interface:MediaPlayback
Emits an error event including the message passed and the exception in the properties- Specified by:
emitErrorEvent
in interfaceMediaPlayback<android.media.MediaPlayer>
-