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:- 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
Fields Modifier and Type Field Description protected java.lang.String
captionsPath
Deprecated.protected android.content.Context
context
protected long
fromSeekPosition
Deprecated.protected boolean
hasSurface
protected boolean
isFrameAvailable
Deprecated.protected RendererConfig
mRendererConfig
protected Source
nextSource
Deprecated.protected Video
nextVideo
Deprecated.protected static int
ON_PLAY_SEEK_THRESHOLD
Deprecated.protected int
playheadPosition
Deprecated.protected long
playheadPositionLong
Deprecated.protected int
progressInterval
Deprecated.protected RenderView
renderView
protected boolean
reseeking
Deprecated.protected long
seekPosition
Deprecated.protected boolean
shouldPlayAudioOnlyInBackground
protected java.util.concurrent.ScheduledFuture<?>
updater
Deprecated.-
Fields inherited from class com.brightcove.player.event.AbstractComponent
eventEmitter, listenerTokens
-
-
Constructor Summary
Constructors Constructor Description VideoDisplayComponent(RenderView renderView, EventEmitter eventEmitter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MediaPlayback<?>
createPlayback()
Create the MediaPlayback for theVideoDisplayComponent
.protected void
destroyPlayer()
Destroys the current player and releases it from memory.protected void
emitErrorEvent(java.lang.String message)
protected void
emitErrorEvent(java.lang.String message, java.lang.Exception exception)
protected void
emitVideoSize(int width, int height)
Analytics
getAnalytics()
Source
getCurrentSource()
Gets reference to the video source that is currently configured for playback, if anySource
getCurrentSourceOrFail()
Gets reference to the video source that is currently configured for playback, if anyVideo
getCurrentVideo()
Gets reference to the video that is currently configured for playback, if anyVideo
getCurrentVideoOrFail()
Gets reference to the video that is currently configured for playback, if anyprotected static java.util.Map<java.lang.String,java.lang.String>
getHeaders(Video video, Source source)
int
getLiveEdge()
Deprecated.long
getLiveEdgeLong()
Obtains the playhead position of the "live edge".android.media.MediaPlayer
getMediaPlayer()
MediaPlayback
getPlayback()
Get the current playback.long
getPlayerCurrentPosition()
Returns the current playhead position of the underlying video player.RenderView
getRenderView()
boolean
hasDvr()
Indicates if Live with DVR is supported.protected void
initializeListeners()
Deprecated.boolean
isCurrentMediaAudioOnly()
boolean
isCurrentVideo360Mode()
boolean
isInLiveEdge()
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<?>
onCreatePlayback()
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
openVideo(Video video, Source source)
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
setTextInformationFrameListener(TextInformationFrameListener listener)
Sets the Text Information Frame Listener.protected void
setVideoSource(Video video, Source source)
Sets the video source that will be used for playback.boolean
shouldPlayAudioOnlyInBackground()
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 Detail
-
ON_PLAY_SEEK_THRESHOLD
@Deprecated protected static final int ON_PLAY_SEEK_THRESHOLD
Deprecated.- See Also:
- Constant Field Values
-
isFrameAvailable
@Deprecated protected boolean isFrameAvailable
Deprecated.
-
renderView
protected RenderView renderView
-
fromSeekPosition
@Deprecated protected long fromSeekPosition
Deprecated.
-
context
protected android.content.Context context
-
updater
@Deprecated protected java.util.concurrent.ScheduledFuture<?> updater
Deprecated.
-
hasSurface
protected boolean hasSurface
-
seekPosition
@Deprecated protected long seekPosition
Deprecated.
-
reseeking
@Deprecated protected boolean reseeking
Deprecated.
-
playheadPosition
@Deprecated protected int playheadPosition
Deprecated.
-
playheadPositionLong
@Deprecated protected long playheadPositionLong
Deprecated.
-
nextVideo
@Deprecated protected Video nextVideo
Deprecated.
-
nextSource
@Deprecated protected Source nextSource
Deprecated.
-
captionsPath
@Deprecated protected java.lang.String captionsPath
Deprecated.
-
progressInterval
@Deprecated protected int progressInterval
Deprecated.
-
mRendererConfig
protected RendererConfig mRendererConfig
-
shouldPlayAudioOnlyInBackground
protected boolean shouldPlayAudioOnlyInBackground
-
-
Constructor Detail
-
VideoDisplayComponent
public VideoDisplayComponent(RenderView renderView, EventEmitter eventEmitter)
-
-
Method Detail
-
setVideoSource
protected void setVideoSource(@Nullable Video video, @Nullable Source source)
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
@Nullable public Video getCurrentVideo()
Gets reference to the video that is currently configured for playback, if any- Returns:
- null or reference to the video
-
getCurrentSource
@Nullable public Source getCurrentSource()
Gets reference to the video source that is currently configured for playback, if any- Returns:
- null or reference to the video source
-
getCurrentVideoOrFail
@NonNull public Video getCurrentVideoOrFail()
Gets reference to the video that is currently configured for playback, if any- Returns:
- reference to the video
- Throws:
java.lang.IllegalStateException
- if there is no video configured.
-
getCurrentSourceOrFail
@NonNull public Source getCurrentSourceOrFail()
Gets reference to the video source that is currently configured for playback, if any- Returns:
- reference to the video source
- Throws:
java.lang.IllegalStateException
- if there is no source configured.
-
setRendererConfig
public void setRendererConfig(RendererConfig rendererConfig)
-
onCreatePlayback
protected MediaPlayback<?> onCreatePlayback()
Called when theVideoDisplayComponent
is initialized.- Returns:
- The media playback for the component.
-
createPlayback
public MediaPlayback<?> createPlayback()
Create the MediaPlayback for theVideoDisplayComponent
.- Returns:
- A new instance of
MediaPlayback
.
-
getPlayback
public 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 public int 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 protected void initializeListeners()
Deprecated.
-
getAnalytics
public Analytics getAnalytics()
-
getRenderView
public RenderView getRenderView()
-
getMediaPlayer
public android.media.MediaPlayer getMediaPlayer()
-
openVideo
protected void openVideo(@NonNull Video video, @Nullable Source source)
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:
java.lang.NullPointerException
- if video is null.
-
getHeaders
protected static java.util.Map<java.lang.String,java.lang.String> getHeaders(Video video, Source source)
-
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
protected void emitErrorEvent(java.lang.String message)
-
emitErrorEvent
protected void emitErrorEvent(java.lang.String message, java.lang.Exception exception)
-
isCurrentVideo360Mode
public boolean isCurrentVideo360Mode()
-
shouldPlayAudioOnlyInBackground
public boolean shouldPlayAudioOnlyInBackground()
-
setShouldPlayAudioOnlyInBackground
public void setShouldPlayAudioOnlyInBackground(boolean play)
-
isCurrentMediaAudioOnly
public boolean isCurrentMediaAudioOnly()
-
setTextInformationFrameListener
public void setTextInformationFrameListener(@NonNull TextInformationFrameListener listener)
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
-
-