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
Nested ClassesModifier and TypeClassDescriptionclassprotected class -
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanprotected Sourceprotected Videofinal android.media.MediaPlayer.OnBufferingUpdateListenerfinal android.media.MediaPlayer.OnCompletionListenerfinal android.media.MediaPlayer.OnErrorListenerfinal android.media.MediaPlayer.OnInfoListenerfinal android.media.MediaPlayer.OnPreparedListenerfinal android.media.MediaPlayer.OnSeekCompleteListenerprotected intprotected ScheduledFuture<?>Fields inherited from class com.brightcove.player.event.AbstractComponent
listenerTokens -
Constructor Summary
ConstructorsConstructorDescriptionMediaPlayerPlayback(RenderView renderView, android.content.Context context, EventEmitter eventEmitter) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the video to the video list at the specified index.voidAdds the video to the end of the video list.voidaddAll(int index, Collection<Video> videos) Inserts all videos in the collection at the specified index.voidaddAll(Collection<Video> videos) Add all videos in the collection to the end of the list.voidclear()Removes all videos from the list.voidDestroys the current player and releases it from memory.voidemitErrorEvent(String message) Emits an error event with the message passed in the event's propertiesvoidemitErrorEvent(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.intReturns the buffer percentageintGets the index from the current videolongReturns the current playhead position of the underlying video player.Get the current source for theVideo.Get the currently playing video.longObtains the playhead position of the "live edge".Get the object which handles showing an on-going player notification.android.media.MediaPlayerGet 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 indexfloatbooleanhasDvr()Indicates if Live with DVR is supported.booleanReturns true if the video is a 360 video otherwise returns falsebooleanChecks the current playhead position with the live edge position and determines if it is in live edge.booleanisLive()Provides a default for handling live videos.booleanbooleanCheck if the player is currently playing and the media is audio-only.booleanReturns if a source has been setvoidonTaskRemoved(android.content.Intent rootIntent) This is called when theMediaPlaybackServiceis currently running and the user has removed a task that comes from the service's application.voidPrepares the player to play the current video source.voidCreates, configures, and prepares a new instance of MediaPlaybackvoidremove(int index) Removes the video at the specified index.voidsetCurrentIndex(int index) Sets the current video to the specified index.voidsetProgressInterval(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.voidsetVideoSource(Video video, Source source) Sets the video source that will be used for playback.protected voidprotected voidMethods inherited from class com.brightcove.player.event.AbstractComponent
addListener, addOnceListener, getEventEmitter, removeListener, removeListenersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:MediaPlaybackCreates, configures, and prepares a new instance of MediaPlayback- Specified by:
openVideoin 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:
openCurrentVideoSourcein interfaceMediaPlayback<android.media.MediaPlayer>
-
getSourceController
Description copied from interface:MediaPlaybackThe source selector which uses a delegate to select sources.- Specified by:
getSourceControllerin 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:
destroyPlayerin interfaceMediaPlayback<android.media.MediaPlayer>- See Also:
-
MediaPlayerSurfaceView
-
setVideoSource
Sets the video source that will be used for playback.- Specified by:
setVideoSourcein 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:MediaPlaybackGet the player used for media playback.- Specified by:
getPlayerin interfaceMediaPlayback<android.media.MediaPlayer>- Returns:
- The media player.
-
getCurrentVideo
Description copied from interface:MediaPlaybackGet the currently playing video.- Specified by:
getCurrentVideoin interfaceMediaPlayback<android.media.MediaPlayer>- Returns:
- The current media object.
-
getCurrentSource
Description copied from interface:MediaPlaybackGet the current source for theVideo.- Specified by:
getCurrentSourcein interfaceMediaPlayback<android.media.MediaPlayer>- Returns:
- The source used for playback.
-
isPlayingAudioOnly
public boolean isPlayingAudioOnly()Description copied from interface:MediaPlaybackCheck if the player is currently playing and the media is audio-only.- Specified by:
isPlayingAudioOnlyin interfaceMediaPlayback<android.media.MediaPlayer>- Returns:
- True if the player is currently playing audio-only media; false otherwise.
-
getAnalytics
Description copied from interface:MediaPlaybackReturns the analytics component, the part of the player that monitors and tracks video playback and engagement.- Specified by:
getAnalyticsin interfaceMediaPlayback<android.media.MediaPlayer>- Returns:
- the analytics component
-
onTaskRemoved
public void onTaskRemoved(android.content.Intent rootIntent) Description copied from interface:MediaPlaybackThis is called when theMediaPlaybackServiceis currently running and the user has removed a task that comes from the service's application.- Specified by:
onTaskRemovedin 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:MediaPlaybackGet the object which handles showing an on-going player notification.- Specified by:
getNotificationin interfaceMediaPlayback<android.media.MediaPlayer>- Returns:
- An object to configure the on-going playback notification.
-
getPlaylist
Description copied from interface:MediaPlaybackReturns a immutable copy of the video list.- Specified by:
getPlaylistin interfaceMediaPlayback<android.media.MediaPlayer>
-
isPlaying
public boolean isPlaying()- Specified by:
isPlayingin 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:
hasDvrin interfaceMediaPlayback<android.media.MediaPlayer>- Returns:
TRUEiff 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:
isLivein interfaceMediaPlayback<android.media.MediaPlayer>- Returns:
TRUEiff live video is supported.
-
getLiveEdge
public long getLiveEdge()Obtains the playhead position of the "live edge".- Specified by:
getLiveEdgein 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:
isInLiveEdgein 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_UNSETwill returned.- Specified by:
getCurrentPositionin 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:
setProgressIntervalin interfaceMediaPlayback<android.media.MediaPlayer>- Parameters:
progressInterval- the PROGRESS interval in milliseconds
-
add
Description copied from interface:MediaPlaybackAdds the video to the end of the video list.- Specified by:
addin interfaceMediaPlayback<android.media.MediaPlayer>
-
add
Description copied from interface:MediaPlaybackAdds the video to the video list at the specified index.- Specified by:
addin interfaceMediaPlayback<android.media.MediaPlayer>
-
addAll
Description copied from interface:MediaPlaybackAdd all videos in the collection to the end of the list.- Specified by:
addAllin interfaceMediaPlayback<android.media.MediaPlayer>- Parameters:
videos- The videos to append.
-
addAll
Description copied from interface:MediaPlaybackInserts all videos in the collection at the specified index.- Specified by:
addAllin interfaceMediaPlayback<android.media.MediaPlayer>
-
setVideoPath
Description copied from interface:MediaPlaybackReplaces player content with the video at the specified path.- Specified by:
setVideoPathin interfaceMediaPlayback<android.media.MediaPlayer>- Parameters:
path- HTTP path to a video- Returns:
- The created Video object.
-
setVideoPath
Description copied from interface:MediaPlaybackReplace player content with the video and captions at the specified paths.- Specified by:
setVideoPathin interfaceMediaPlayback<android.media.MediaPlayer>- Parameters:
videoPath- HTTP path to the videolanguageCodeCaptionsMap- A map of language code to caption urls.
-
getVideoAt
Description copied from interface:MediaPlaybackGets a video from the video list at the specified index- Specified by:
getVideoAtin interfaceMediaPlayback<android.media.MediaPlayer>
-
getCurrentIndex
public int getCurrentIndex()Description copied from interface:MediaPlaybackGets the index from the current video- Specified by:
getCurrentIndexin 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:MediaPlaybackSets the current video to the specified index.- Specified by:
setCurrentIndexin interfaceMediaPlayback<android.media.MediaPlayer>
-
remove
Description copied from interface:MediaPlaybackRemoves the video at the specified index.- Specified by:
removein 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:MediaPlaybackRemoves all videos from the list.- Specified by:
clearin interfaceMediaPlayback<android.media.MediaPlayer>
-
getBufferPercentage
public int getBufferPercentage()Description copied from interface:MediaPlaybackReturns the buffer percentage- Specified by:
getBufferPercentagein interfaceMediaPlayback<android.media.MediaPlayer>
-
getVolume
public float getVolume()- Specified by:
getVolumein interfaceMediaPlayback<android.media.MediaPlayer>
-
isSourceSet
public boolean isSourceSet()Description copied from interface:MediaPlaybackReturns if a source has been set- Specified by:
isSourceSetin interfaceMediaPlayback<android.media.MediaPlayer>
-
isCurrentVideo360Mode
public boolean isCurrentVideo360Mode()Description copied from interface:MediaPlaybackReturns true if the video is a 360 video otherwise returns false- Specified by:
isCurrentVideo360Modein interfaceMediaPlayback<android.media.MediaPlayer>
-
emitErrorEvent
Description copied from interface:MediaPlaybackEmits an error event with the message passed in the event's properties- Specified by:
emitErrorEventin interfaceMediaPlayback<android.media.MediaPlayer>
-
emitErrorEvent
Description copied from interface:MediaPlaybackEmits an error event including the message passed and the exception in the properties- Specified by:
emitErrorEventin interfaceMediaPlayback<android.media.MediaPlayer>
-