public class DefaultEmbeddedMediaPlayer extends DefaultMediaPlayer implements EmbeddedMediaPlayer
This implementation supports the use of an 'overlay' window that will track the video surface position and size. Such an overlay could be used to paint custom graphics over the top of the video.
The overlay window should be non-opaque - support for this depends on the JVM, desktop window manager and graphics device hardware and software.
The overlay also has some significant limitations, it is a component that covers the video surface component and will prevent mouse and keyboard events from being processed by the video surface. Workarounds to delegate the mouse and keyboard events to the underlying Canvas may be possible but that is a responsibility of the overlay component itself and not these bindings.
The overlay will also 'lag' the main application frame when the frame is dragged - the event used to track the frame position does not fire until after the window drag operation has completed (i.e. the mouse pointer is released).
A further limitation is that the overlay will not appear when full-screen exclusive mode is used - if an overlay is required in full-screen mode then the full-screen mode must be simulated (by re-sizing the main window, removing decorations and so on).
If an overlay is used, then because the window is required to be non-opaque then it will appear in front of all other desktop windows, including application dialog windows. For this reason, it may be necessary to disable the overlay while displaying dialog boxes, or when the window is deactivated.
The overlay implementation in this class simply keeps a supplied window in sync with the video surface. It is the responsibility of the client application itself to supply an appropriate overlay component.
Finally, the overlay is experimental and support for the overlay may be changed or removed.
Constructor and Description |
---|
DefaultEmbeddedMediaPlayer(LibVlc libvlc,
libvlc_instance_t instance)
Create a new media player.
|
DefaultEmbeddedMediaPlayer(LibVlc libvlc,
libvlc_instance_t instance,
FullScreenStrategy fullScreenStrategy)
Create a new media player.
|
Modifier and Type | Method and Description |
---|---|
void |
attachVideoSurface()
Ensure that the video surface has been associated with the native media player.
|
void |
enableOverlay(boolean enable)
Enable/disable the overlay component if there is one.
|
Window |
getOverlay()
Get the overlay component.
|
BufferedImage |
getVideoSurfaceContents()
Get the contents of the video surface component.
|
boolean |
isFullScreen()
Check whether the full-screen mode is currently active or not.
|
boolean |
overlayEnabled()
Check whether or not there is an overlay component currently enabled.
|
void |
setEnableKeyInputHandling(boolean enable)
Set whether or not to enable native media player keyboard input handling.
|
void |
setEnableMouseInputHandling(boolean enable)
Set whether or not to enable native media player mouse input handling.
|
void |
setFullScreen(boolean fullScreen)
Set full-screen mode.
|
void |
setFullScreenStrategy(FullScreenStrategy fullScreenStrategy)
Set a full-screen strategy implementation.
|
void |
setOverlay(Window overlay)
Set a new overlay component.
|
void |
setVideoSurface(CanvasVideoSurface videoSurface)
Set the component used to render video.
|
void |
toggleFullScreen()
Toggle whether the video display is in full-screen or not.
|
addMediaOptions, addMediaPlayerEventListener, canPause, cycleSpu, enableEvents, enableLogo, enableMarquee, equalizerChanged, getAllChapterDescriptions, getAspectRatio, getAudioChannel, getAudioDelay, getAudioDescriptions, getAudioOutputDevice, getAudioOutputDevices, getAudioTrack, getAudioTrackCount, getBrightness, getChapter, getChapterCount, getChapterDescriptions, getChapterDescriptions, getCodecDescription, getContrast, getCropGeometry, getEqualizer, getFps, getGamma, getHue, getLength, getMediaDetails, getMediaMeta, getMediaMeta, getMediaPlayerState, getMediaState, getMediaStatistics, getMediaStatistics, getPosition, getRate, getRepeat, getSaturation, getScale, getSnapshot, getSnapshot, getSpu, getSpuCount, getSpuDelay, getSpuDescriptions, getSubItemMediaMeta, getSubItemTrackInfo, getTeletextPage, getTime, getTitle, getTitleCount, getTitleDescriptions, getTrackInfo, getTrackInfo, getVideoDescriptions, getVideoDimension, getVideoOutputs, getVideoTrack, getVideoTrackCount, getVolume, isAdjustVideo, isMediaParsed, isMute, isPlayable, isPlaying, isSeekable, mediaPlayerInstance, menuActivate, menuDown, menuLeft, menuRight, menuUp, mrl, mrl, mute, mute, nextChapter, nextFrame, parseMedia, pause, play, playMedia, playNextSubItem, playSubItem, prepareMedia, previousChapter, programScrambled, release, removeMediaPlayerEventListener, requestParseMedia, requestParseMediaWithOptions, saveSnapshot, saveSnapshot, saveSnapshot, saveSnapshot, setAdjustVideo, setAspectRatio, setAudioChannel, setAudioDelay, setAudioOutput, setAudioOutputDevice, setAudioTrack, setBrightness, setChapter, setContrast, setCropGeometry, setDeinterlace, setEqualizer, setGamma, setHue, setLogoFile, setLogoImage, setLogoLocation, setLogoOpacity, setLogoOpacity, setLogoPosition, setMarqueeColour, setMarqueeColour, setMarqueeLocation, setMarqueeOpacity, setMarqueeOpacity, setMarqueePosition, setMarqueeSize, setMarqueeText, setMarqueeTimeout, setPause, setPlaySubItems, setPosition, setRate, setRepeat, setSaturation, setScale, setSnapshotDirectory, setSpu, setSpuDelay, setStandardMediaOptions, setSubTitleFile, setSubTitleFile, setTeletextPage, setTime, setTitle, setVideoTitleDisplay, setVideoTrack, setVolume, skip, skipPosition, start, startMedia, stop, subItemCount, subItemIndex, subItems, subItemsMedia, subItemsMediaList, toggleTeletext, userData, userData
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addMediaOptions, addMediaPlayerEventListener, canPause, cycleSpu, enableEvents, enableLogo, enableMarquee, getAllChapterDescriptions, getAspectRatio, getAudioChannel, getAudioDelay, getAudioDescriptions, getAudioOutputDevice, getAudioOutputDevices, getAudioTrack, getAudioTrackCount, getBrightness, getChapter, getChapterCount, getChapterDescriptions, getChapterDescriptions, getCodecDescription, getContrast, getCropGeometry, getEqualizer, getFps, getGamma, getHue, getLength, getMediaDetails, getMediaMeta, getMediaMeta, getMediaPlayerState, getMediaState, getMediaStatistics, getMediaStatistics, getPosition, getRate, getRepeat, getSaturation, getScale, getSnapshot, getSnapshot, getSpu, getSpuCount, getSpuDelay, getSpuDescriptions, getSubItemMediaMeta, getSubItemTrackInfo, getTeletextPage, getTime, getTitle, getTitleCount, getTitleDescriptions, getTrackInfo, getTrackInfo, getVideoDescriptions, getVideoDimension, getVideoOutputs, getVideoTrack, getVideoTrackCount, getVolume, isAdjustVideo, isMediaParsed, isMute, isPlayable, isPlaying, isSeekable, mediaPlayerInstance, menuActivate, menuDown, menuLeft, menuRight, menuUp, mrl, mrl, mute, mute, nextChapter, nextFrame, parseMedia, pause, play, playMedia, playNextSubItem, playSubItem, prepareMedia, previousChapter, programScrambled, release, removeMediaPlayerEventListener, requestParseMedia, requestParseMediaWithOptions, saveSnapshot, saveSnapshot, saveSnapshot, saveSnapshot, setAdjustVideo, setAspectRatio, setAudioChannel, setAudioDelay, setAudioOutput, setAudioOutputDevice, setAudioTrack, setBrightness, setChapter, setContrast, setCropGeometry, setDeinterlace, setEqualizer, setGamma, setHue, setLogoFile, setLogoImage, setLogoLocation, setLogoOpacity, setLogoOpacity, setLogoPosition, setMarqueeColour, setMarqueeColour, setMarqueeLocation, setMarqueeOpacity, setMarqueeOpacity, setMarqueePosition, setMarqueeSize, setMarqueeText, setMarqueeTimeout, setPause, setPlaySubItems, setPosition, setRate, setRepeat, setSaturation, setScale, setSnapshotDirectory, setSpu, setSpuDelay, setStandardMediaOptions, setSubTitleFile, setSubTitleFile, setTeletextPage, setTime, setTitle, setVideoTitleDisplay, setVideoTrack, setVolume, skip, skipPosition, start, startMedia, stop, subItemCount, subItemIndex, subItems, subItemsMedia, subItemsMediaList, toggleTeletext, userData, userData
public DefaultEmbeddedMediaPlayer(LibVlc libvlc, libvlc_instance_t instance)
Full-screen will not be supported.
libvlc
- native interfaceinstance
- libvlc instancepublic DefaultEmbeddedMediaPlayer(LibVlc libvlc, libvlc_instance_t instance, FullScreenStrategy fullScreenStrategy)
libvlc
- native interfaceinstance
- libvlc instancefullScreenStrategy
- full-screen strategy implementationpublic void setVideoSurface(CanvasVideoSurface videoSurface)
EmbeddedMediaPlayer
Setting the video surface on the native component is actually deferred so the component used as the video surface need not be visible and fully realised before calling this method.
The video surface will not be associated with the native media player until the media is played.
It is possible to change the video surface after it has been set, but the change will not take effect until the media is played.
setVideoSurface
in interface EmbeddedMediaPlayer
videoSurface
- component to render video topublic void attachVideoSurface()
EmbeddedMediaPlayer
Ordinarily when setting the video surface the actual association of the video surface with the native media player is deferred until the first time media is played.
This deferring behaviour is usually a good thing because when setting a video surface component on the native media player the video surface component must be a displayable component and this is often not the case during the construction and initialisation of the application.
Most applications will not need to call this method.
However, in special circumstances such as associating an embedded media player with a media list player, media is played through the media list rather than the media player itself so the deferred association of the video surface would never happen.
Calling this method ensures that the video surface is properly associated with the native media player and consequently the video surface component must be visible when this method is called.
attachVideoSurface
in interface EmbeddedMediaPlayer
public void setFullScreenStrategy(FullScreenStrategy fullScreenStrategy)
EmbeddedMediaPlayer
The preferred way to set a full-screen strategy is via a constructor argument, nevertheless there are scenarios where it is more convenient to set the full-screen strategy after creation of the media player (depends how the application UI is created).
Applications should not change the full-screen strategy implementation after initialisation of the media player. Doing so makes no practical sense and the resultant behaviour is undefined.
setFullScreenStrategy
in interface EmbeddedMediaPlayer
fullScreenStrategy
- full-screen strategypublic void toggleFullScreen()
EmbeddedMediaPlayer
Setting the display into or out of full-screen mode is delegate to the
FullScreenStrategy
that was used when the media player was created.
toggleFullScreen
in interface EmbeddedMediaPlayer
public void setFullScreen(boolean fullScreen)
EmbeddedMediaPlayer
Setting the display into or out of full-screen mode is delegate to the
FullScreenStrategy
that was used when the media player was created.
setFullScreen
in interface EmbeddedMediaPlayer
fullScreen
- true for full-screen, otherwise falsepublic boolean isFullScreen()
EmbeddedMediaPlayer
Testing whether or not the display is in full-screen mode is delegate to the
FullScreenStrategy
that was used when the media player was created.
isFullScreen
in interface EmbeddedMediaPlayer
public BufferedImage getVideoSurfaceContents()
EmbeddedMediaPlayer
The implementation is expected to use the AWT Robot class to capture the contents of the video surface component (there is no other way).
The size of the returned image will match the current size of the video surface.
Since this implementation will use the AWT Robot class to make a screen capture, care must be taken when invoking this method to ensure that nothing else is overlaying the video surface!
getVideoSurfaceContents
in interface EmbeddedMediaPlayer
public Window getOverlay()
EmbeddedMediaPlayer
getOverlay
in interface EmbeddedMediaPlayer
null
public void setOverlay(Window overlay)
EmbeddedMediaPlayer
The existing overlay if there is one will be disabled.
The new overlay will not automatically be enabled.
The overlay should be a sub-class of Window
or JWindow
. If your
overlay contains dynamically updated content such as a timer or animated graphics, then you
should use JWindow
so that your updates will be double-buffered and there will
be no tearing or flickering when you paint the overlay. If you do this, you must take care to
erase the overlay background before you paint it.
setOverlay
in interface EmbeddedMediaPlayer
overlay
- overlay component, may be null
public void enableOverlay(boolean enable)
EmbeddedMediaPlayer
enableOverlay
in interface EmbeddedMediaPlayer
enable
- whether to enable the overlay or disable itpublic boolean overlayEnabled()
EmbeddedMediaPlayer
overlayEnabled
in interface EmbeddedMediaPlayer
public void setEnableMouseInputHandling(boolean enable)
EmbeddedMediaPlayer
It may be necessary on some platforms to invoke this method with a false
parameter
value for Java mouse and keyboard listeners to work.
Note that clicking the video surface on certain platforms is not guaranteed to capture mouse events - it may be necessary to respond to a mouse pressed event on the video surface and explicitly request the input focus to the video surface.
setEnableMouseInputHandling
in interface EmbeddedMediaPlayer
enable
- true
to enable, false
to disablepublic void setEnableKeyInputHandling(boolean enable)
EmbeddedMediaPlayer
It may be necessary on some platforms to invoke this method with a false
parameter
value for Java mouse and keyboard listeners to work.
setEnableKeyInputHandling
in interface EmbeddedMediaPlayer
enable
- true
to enable, false
to disableCopyright © 2009–2015 Caprica Software Limited. All rights reserved.