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 |
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, getAllChapterDescriptions, getAspectRatio, getAudioChannel, getAudioDelay, getAudioDescriptions, getAudioOutputDeviceType, getAudioTrack, getAudioTrackCount, getBrightness, getChapter, getChapterCount, getChapterDescriptions, getChapterDescriptions, getContrast, getCropGeometry, 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, release, removeMediaPlayerEventListener, requestParseMedia, saveSnapshot, saveSnapshot, saveSnapshot, saveSnapshot, setAdjustVideo, setAspectRatio, setAudioChannel, setAudioDelay, setAudioOutput, setAudioOutputDevice, setAudioOutputDeviceType, setAudioTrack, setBrightness, setChapter, setContrast, setCropGeometry, setDeinterlace, 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, setVideoTrack, setVolume, skip, skipPosition, start, startMedia, stop, subItemCount, subItemIndex, subItems, subItemsMedia, toggleTeletext, userData, userDataequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddMediaOptions, addMediaPlayerEventListener, canPause, cycleSpu, enableEvents, enableLogo, enableMarquee, getAllChapterDescriptions, getAspectRatio, getAudioChannel, getAudioDelay, getAudioDescriptions, getAudioOutputDeviceType, getAudioTrack, getAudioTrackCount, getBrightness, getChapter, getChapterCount, getChapterDescriptions, getChapterDescriptions, getContrast, getCropGeometry, 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, release, removeMediaPlayerEventListener, requestParseMedia, saveSnapshot, saveSnapshot, saveSnapshot, saveSnapshot, setAdjustVideo, setAspectRatio, setAudioChannel, setAudioDelay, setAudioOutput, setAudioOutputDevice, setAudioOutputDeviceType, setAudioTrack, setBrightness, setChapter, setContrast, setCropGeometry, setDeinterlace, 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, setVideoTrack, setVolume, skip, skipPosition, start, startMedia, stop, subItemCount, subItemIndex, subItems, subItemsMedia, toggleTeletext, userData, userDatapublic 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 - public void setVideoSurface(CanvasVideoSurface videoSurface)
EmbeddedMediaPlayerSetting 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 EmbeddedMediaPlayervideoSurface - component to render video topublic void attachVideoSurface()
EmbeddedMediaPlayerOrdinarily 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 EmbeddedMediaPlayerpublic 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 EmbeddedMediaPlayerpublic 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 EmbeddedMediaPlayerfullScreen - 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 EmbeddedMediaPlayerpublic BufferedImage getVideoSurfaceContents()
EmbeddedMediaPlayerThe 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 EmbeddedMediaPlayerpublic Window getOverlay()
EmbeddedMediaPlayergetOverlay in interface EmbeddedMediaPlayernullpublic void setOverlay(Window overlay)
EmbeddedMediaPlayerThe 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 EmbeddedMediaPlayeroverlay - overlay component, may be nullpublic void enableOverlay(boolean enable)
EmbeddedMediaPlayerenableOverlay in interface EmbeddedMediaPlayerenable - whether to enable the overlay or disable itpublic boolean overlayEnabled()
EmbeddedMediaPlayeroverlayEnabled in interface EmbeddedMediaPlayerpublic void setEnableMouseInputHandling(boolean enable)
EmbeddedMediaPlayersetEnableMouseInputHandling in interface EmbeddedMediaPlayerenable - true to enable, false to disablepublic void setEnableKeyInputHandling(boolean enable)
EmbeddedMediaPlayersetEnableKeyInputHandling in interface EmbeddedMediaPlayerenable - true to enable, false to disableCopyright © 2009-2012 Caprica Software Limited. All Rights Reserved.