Package com.brightcove.player.display
Class VideoDisplayComponent
java.lang.Object
com.brightcove.player.event.AbstractComponent
com.brightcove.player.display.VideoDisplayComponent
- All Implemented Interfaces:
Component
- Direct Known Subclasses:
ExoPlayerVideoDisplayComponent
@Emits(events={"bufferedUpdate","completed","didInterruptContent","didPause","didPlay","didResumeContent","didSeekTo","didSetSource","didStop","error","pause","play","progress","sourceNotPlayable","stop","videoDurationChanged","videoSizeKnown","willChangeVideo","readyToPlay"})
@ListensFor(events={"completed","didSetSource","pause","play","prebufferNextVideo","seekTo","setSource","stop","videoDurationChanged","willChangeVideo","willInterruptContent","willResumeContent","readyToPlay","setVolume","didSetVideo","on360FrameAvailable","didSeekTo"})
public class VideoDisplayComponent
extends AbstractComponent
The VideoDisplayComponent wraps the Brightcove EventEmitter around the lifecycle of the standard Android MediaPlayer
API. The intended goal is that the end developer should never have to interact directly with the MediaPlayer instance,
but rather only have to fire events at it via the EventEmitter.
LifeCycle
To begin playing, the VideoDisplayComponent (VDC) must first receive a EventType.SET_SOURCE event, containing a valid Source parameter. Once the source is set, the VDC will emit EventType.DID_SET_SOURCE.
Once set, the the VDC will respond to the following events:
In addition, the VDC will emit Progress , buffering, and video_completed events.
LifeCycle
To begin playing, the VideoDisplayComponent (VDC) must first receive a EventType.SET_SOURCE event, containing a valid Source parameter. Once the source is set, the VDC will emit EventType.DID_SET_SOURCE.
Once set, the the VDC will respond to the following events:
- EventType.PLAY: plays the video / resumes playback if paused
- EventType.PAUSE: pauses the video
- EventType.SEEK_TO: seeks to the position
- EventType.STOP: stops the video and destroys the player
In addition, the VDC will emit Progress , buffering, and video_completed events.
- See Also:
-
MediaPlayer
Source
AbstractComponent
EventEmitter
EventType
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
Deprecated.protected android.content.Context
protected long
Deprecated.protected boolean
protected boolean
Deprecated.protected RendererConfig
protected Source
Deprecated.protected Video
Deprecated.protected static final int
Deprecated.protected int
Deprecated.protected long
Deprecated.protected int
Deprecated.protected RenderView
protected boolean
Deprecated.protected long
Deprecated.protected boolean
protected ScheduledFuture<?>
Deprecated.Fields inherited from class com.brightcove.player.event.AbstractComponent
eventEmitter, listenerTokens
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreate the MediaPlayback for theVideoDisplayComponent
.protected void
Destroys the current player and releases it from memory.protected void
emitErrorEvent
(String message) protected void
emitErrorEvent
(String message, Exception exception) protected void
emitVideoSize
(int width, int height) Gets reference to the video source that is currently configured for playback, if anyGets reference to the video source that is currently configured for playback, if anyGets reference to the video that is currently configured for playback, if anyGets reference to the video that is currently configured for playback, if anygetHeaders
(Video video, Source source) int
Deprecated.long
Obtains the playhead position of the "live edge".android.media.MediaPlayer
Get the current playback.long
Returns the current playhead position of the underlying video player.boolean
hasDvr()
Indicates if Live with DVR is supported.protected void
Deprecated.boolean
boolean
boolean
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.protected MediaPlayback<?>
Called when theVideoDisplayComponent
is initialized.void
onSurfaceTextureAvailable
(android.graphics.SurfaceTexture surfaceTexture, int width, int height) void
onSurfaceTextureDestroyed
(android.graphics.SurfaceTexture surfaceTexture) void
onSurfaceTextureSizeChanged
(android.graphics.SurfaceTexture surfaceTexture, int width, int height) void
onSurfaceTextureUpdated
(android.graphics.SurfaceTexture surfaceTexture) protected void
Creates, configures, and prepares a new instance of MediaPlayervoid
setProgressInterval
(int progressInterval) Sets the the interval in milliseconds at which to fire PROGRESS events during playback.void
setRendererConfig
(RendererConfig rendererConfig) void
setShouldPlayAudioOnlyInBackground
(boolean play) void
Sets the Text Information Frame Listener.protected void
setVideoSource
(Video video, Source source) Sets the video source that will be used for playback.boolean
void
surfaceChanged
(android.view.SurfaceHolder surfaceHolder, int format, int width, int height) void
surfaceCreated
(android.view.SurfaceHolder surfaceHolder) void
surfaceDestroyed
(android.view.SurfaceHolder surfaceHolder) Methods inherited from class com.brightcove.player.event.AbstractComponent
addListener, addOnceListener, getEventEmitter, removeListener, removeListeners
-
Field Details
-
ON_PLAY_SEEK_THRESHOLD
Deprecated.- See Also:
-
isFrameAvailable
Deprecated. -
renderView
-
fromSeekPosition
Deprecated. -
context
protected android.content.Context context -
updater
Deprecated. -
hasSurface
protected boolean hasSurface -
seekPosition
Deprecated. -
reseeking
Deprecated. -
playheadPosition
Deprecated. -
playheadPositionLong
Deprecated. -
nextVideo
Deprecated. -
nextSource
Deprecated. -
progressInterval
Deprecated. -
mRendererConfig
-
shouldPlayAudioOnlyInBackground
protected boolean shouldPlayAudioOnlyInBackground
-
-
Constructor Details
-
VideoDisplayComponent
-
-
Method Details
-
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.
-
getCurrentVideo
Gets reference to the video that is currently configured for playback, if any- Returns:
- null or reference to the video
-
getCurrentSource
Gets reference to the video source that is currently configured for playback, if any- Returns:
- null or reference to the video source
-
getCurrentVideoOrFail
Gets reference to the video that is currently configured for playback, if any- Returns:
- reference to the video
- Throws:
IllegalStateException
- if there is no video configured.
-
getCurrentSourceOrFail
Gets reference to the video source that is currently configured for playback, if any- Returns:
- reference to the video source
- Throws:
IllegalStateException
- if there is no source configured.
-
setRendererConfig
-
onCreatePlayback
Called when theVideoDisplayComponent
is initialized.- Returns:
- The media playback for the component.
-
createPlayback
Create the MediaPlayback for theVideoDisplayComponent
.- Returns:
- A new instance of
MediaPlayback
.
-
getPlayback
Get the current playback.- Returns:
- The
MediaPlayback
for thisVideoDisplayComponent
.
-
hasDvr
public boolean hasDvr()Indicates if Live with DVR is supported. Subclasses will override if live with DVR videos are supported.- 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.- Returns:
TRUE
iff live video is supported.
-
getLiveEdge
Deprecated.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.
-
getLiveEdgeLong
public long getLiveEdgeLong()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
public boolean isInLiveEdge()Checks the current playhead position with the live edge position and determines if it is in live edge.- Returns:
- true if in live edge.
-
getPlayerCurrentPosition
public long getPlayerCurrentPosition()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
public 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
-
initializeListeners
Deprecated. -
getAnalytics
-
getRenderView
-
getMediaPlayer
public android.media.MediaPlayer getMediaPlayer() -
openVideo
Creates, configures, and prepares a new instance of MediaPlayer- 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.
-
getHeaders
-
destroyPlayer
protected 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- See Also:
-
MediaPlayer
SurfaceView
-
emitVideoSize
protected void emitVideoSize(int width, int height) -
surfaceCreated
public void surfaceCreated(android.view.SurfaceHolder surfaceHolder) -
surfaceChanged
public void surfaceChanged(android.view.SurfaceHolder surfaceHolder, int format, int width, int height) -
surfaceDestroyed
public void surfaceDestroyed(android.view.SurfaceHolder surfaceHolder) -
onSurfaceTextureAvailable
public void onSurfaceTextureAvailable(android.graphics.SurfaceTexture surfaceTexture, int width, int height) -
onSurfaceTextureSizeChanged
public void onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture surfaceTexture, int width, int height) -
onSurfaceTextureDestroyed
public void onSurfaceTextureDestroyed(android.graphics.SurfaceTexture surfaceTexture) -
onSurfaceTextureUpdated
public void onSurfaceTextureUpdated(android.graphics.SurfaceTexture surfaceTexture) -
emitErrorEvent
-
emitErrorEvent
-
isCurrentVideo360Mode
public boolean isCurrentVideo360Mode() -
shouldPlayAudioOnlyInBackground
public boolean shouldPlayAudioOnlyInBackground() -
setShouldPlayAudioOnlyInBackground
public void setShouldPlayAudioOnlyInBackground(boolean play) -
isCurrentMediaAudioOnly
public boolean isCurrentMediaAudioOnly() -
setTextInformationFrameListener
Sets the Text Information Frame Listener.TextInformationFrameListener.onTextInformationFrame(TextInformationFrame, long)
will be called when the player finds an ID3 Metadata of typeTextInformationFrame
in the Video.Use
TextInformationFrameListener.DISABLED
to disable the listener.- Parameters:
listener
- the listener
-