|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.co.caprica.vlcj.player.MediaPlayer
uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer
public abstract class EmbeddedMediaPlayer
Implementation of a media player that renders video to an embedded Canvas component.
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.
Field Summary |
---|
Fields inherited from class uk.co.caprica.vlcj.player.MediaPlayer |
---|
libvlc |
Constructor Summary | |
---|---|
EmbeddedMediaPlayer(libvlc_instance_t instance)
Create a new media player. |
|
EmbeddedMediaPlayer(libvlc_instance_t instance,
FullScreenStrategy fullScreenStrategy)
Create a new media player. |
Method Summary | |
---|---|
void |
enableOverlay(boolean enable)
Enable/disable the overlay component if there is one. |
java.awt.Window |
getOverlay()
Get the overlay component. |
java.awt.image.BufferedImage |
getVideoSurfaceContents()
Get the contents of the video surface component. |
boolean |
isFullScreen()
Test the current full-screen mode. |
protected abstract void |
nativeSetVideoSurface(libvlc_media_player_t instance,
java.awt.Canvas videoSurface)
Template method for setting the video surface natively. |
protected void |
onBeforePlay()
Allow sub-classes to do something just before the video is started. |
boolean |
overlayEnabled()
Check whether or not there is an overlay component currently enabled. |
void |
setFullScreen(boolean fullScreen)
Set full-screen mode. |
void |
setOverlay(java.awt.Window overlay)
Set a new overlay component. |
void |
setVideoSurface(java.awt.Canvas videoSurface)
Set the component used to render video. |
void |
toggleFullScreen()
Toggle whether the video display is in full-screen or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EmbeddedMediaPlayer(libvlc_instance_t instance)
Full-screen will not be supported.
instance
- libvlc instancepublic EmbeddedMediaPlayer(libvlc_instance_t instance, FullScreenStrategy fullScreenStrategy)
instance
- liblc instancefullScreenStrategy
- Method Detail |
---|
public void setVideoSurface(java.awt.Canvas videoSurface)
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.
videoSurface
- component to render video topublic void toggleFullScreen()
This method defers to the full-screen strategy implementation.
public void setFullScreen(boolean fullScreen)
This method defers to the full-screen strategy implementation.
fullScreen
- true for full-screen, otherwise falsepublic boolean isFullScreen()
This method defers to the full-screen strategy implementation.
public java.awt.image.BufferedImage getVideoSurfaceContents()
This implementation uses the AWT Robot class to capture the contents of the video surface component.
The size of the returned image will match the current size of the video surface.
Since this implementation uses 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!
public java.awt.Window getOverlay()
null
public void setOverlay(java.awt.Window overlay)
The existing overlay if there is one will be disabled.
The new overlay will not automatically be enabled.
overlay
- overlay componentpublic void enableOverlay(boolean enable)
enable
- whether to enable the overlay or disable itpublic boolean overlayEnabled()
protected void onBeforePlay()
MediaPlayer
onBeforePlay
in class MediaPlayer
protected abstract void nativeSetVideoSurface(libvlc_media_player_t instance, java.awt.Canvas videoSurface)
Implementing classes should override this method to invoke the appropriate libvlc method to set the video surface.
instance
- media player instancevideoSurface
- video surface component
|
(C)2010 Caprica Software Limited | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |