Class VLCjDirectRenderPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.visualization.video.vlcjplayer.VLCjDirectRenderPanel
-
- All Implemented Interfaces:
adams.core.CleanUpHandler,adams.gui.core.MenuBarProvider,ImageObserver,MenuContainer,Serializable,Accessible
public class VLCjDirectRenderPanel extends adams.gui.core.BasePanel implements adams.gui.core.MenuBarProvider, adams.core.CleanUpHandlerA basic video player. Allows a user to open, play, and pause video- Author:
- sjb90 (sjb90 at students dot waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected static doubleDEFAULT_RATEthe values used for playback ratestatic StringEVENT_MUTEstatic StringEVENT_PAUSEstatic StringEVENT_PLAYstatic StringEVENT_STOPstatic StringFILENAMEthe properties file name.protected adams.gui.core.BaseButtonm_ButtonMuteMute buttonprotected adams.gui.core.BaseButtonm_ButtonPausethe "pause" buttonprotected adams.gui.core.BaseButtonm_ButtonPlaythe "play" buttonprotected adams.gui.core.BaseButtonm_ButtonStopthe "pause" buttonprotected adams.gui.core.BasePanelm_ControlsPanelthe panel for our video controlsprotected Filem_CurrentFileThe path to the file we're currently viewingprotected adams.core.DateFormatm_dateFormatterDate formatter for outputing timestampsprotected ScheduledExecutorServicem_Executora scheduler to deal with the sliderprotected ScheduledFuture<?>m_ExecutorHandlerthe handler for the scheduled eventprotected adams.gui.chooser.BaseFileChooserm_FileChooserthe file chooserprotected JLabelm_LabelMediaLengthlabel for the length of the current media fileprotected JLabelm_LabelPlaybackTimelabel for timeprotected adams.core.logging.Loggerm_Loggerthe logger used to output information to the adams consoleprotected longm_MediaLengthmedia lengthprotected DirectRenderMediaPlayerPanelm_MediaPlayerComponentthe media player component used to play videoprotected JMenuBarm_MenuBarthe menu bar, if used.protected JMenum_MenuFileLoadRecentthe "load recent" submenu.protected JMenuItemm_MenuItemFileClosethe menu item "close".protected JMenuItemm_MenuItemFileOpenthe menu item "open".protected JMenuItemm_MenuItemSetSpeedthe menu item "Set Speed"protected JMenuItemm_MenuItemVideoPausethe menu item "pause"protected JMenuItemm_MenuItemVideoPlaythe menu item "play"protected JMenuItemm_MenuItemVideoShowHideControlsthe menu item "show/hide controls"protected JMenuItemm_MenuItemVideoStopthe menu item "stop"protected Set<ActionListener>m_MuteListenersthe listeners for the play event.protected Set<ActionListener>m_PauseListenersthe listeners for the play event.protected longm_PlaybackTimecurrent playback timeprotected Set<ActionListener>m_PlayListenersthe listeners for the play event.protected static adams.core.Propertiesm_Propertiesthe properties to use.protected adams.gui.core.RecentFilesHandler<JMenu>m_RecentFilesHandlerfor handling recent files.protected JSliderm_SliderPositionslider for changing video positionprotected SpinnerNumberModelm_SpinnerModelthe model for our spinnerprotected JSpinnerm_SpinnerRatespinner for setting the playback rateprotected Set<ActionListener>m_StopListenersthe listeners for the play event.protected adams.gui.core.TitleGeneratorm_TitleGeneratorfor generating the title.protected booleanm_VideoLoadedflag to say if video is loadedprotected booleanm_VideoPausedflag to say if video is pausedprotected booleanm_VideoPlayingflag for player state, playing/not playingprotected booleanm_VLCInstalledflag to check that VLC is installed.protected static doubleMAX_RATEprotected static doubleMIN_RATEprotected static doubleRATE_STEPstatic StringSESSION_FILEthe file to store the recent files in.-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description VLCjDirectRenderPanel()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMuteListener(ActionListener l)Adds the listener for the mute events.voidaddPauseListener(ActionListener l)Adds the listener for the pause events.voidaddPlayListener(ActionListener l)Adds the listener for the play events.voidaddStopListener(ActionListener l)Adds the listener for the stop events.voidcleanUp()Cleans up data structures, frees up memory.protected voidclose()Closes the dialog, if possible.voidenterPlaybackSpeed()Updates the playback speed with the user entered value.protected voidfinishInit()finishes the initialization.FilegetCurrentFile()protected adams.gui.chooser.BaseFileChoosergetFileChooser()Returns the file chooser to use.JMenuBargetMenuBar()Creates a menu bar (singleton per panel object).protected static adams.core.PropertiesgetProperties()Returns the properties to use for the video player.longgetTimeStamp()Returns the current video time in millisecondsStringgetTitle()Returns the base title in use by the title generator.adams.gui.core.TitleGeneratorgetTitleGenerator()Returns the title generator in use.voidinitGUI()For initializing the GUI.protected voidinitialize()For initializing members.booleanisSoundMuted()Gets the muted state of the soundbooleanisVideoLoaded()Gets the loaded status of the videobooleanisVideoPaused()Gets the paused status of the videobooleanisVideoPlaying()Gets the playing status of the videobooleanisVLCInstalled()Gets the VLC install statusvoidmute()Mutes the videoprotected voidnotifyMuteListeners()Notifies all mute listeners.protected voidnotifyPauseListeners()Notifies all pause listeners.protected voidnotifyPlayListeners()Notifies all play listeners.protected voidnotifyStopListeners()Notifies all stop listeners.booleanopen()Pops up dialog to open a file.booleanopen(File file)Opens the specified file.voidpause()Pauses the video assuming there is a video loaded and playingvoidplay()Plays or stops the video depending on what state it's in currently.voidremoveMuteListener(ActionListener l)Removes the listener for the mute events.voidremovePauseListener(ActionListener l)Removes the listener for the pause events.voidremovePlayListener(ActionListener l)Removes the listener for the play events.voidremoveStopListener(ActionListener l)Removes the listener for the stop events.voidsetPlaybackRate(String rateString)Sets the playback rate to the given ratevoidsetTitle(String value)Sets the base title to use for the title generator.voidshowControls(boolean show)Hides or shows the control panelvoidstop()Stops the videovoidtoggleMute()Toggles the mute state.voidunmute()Unmutes the videoprotected voidupdate()Updates title and menu items.protected voidupdateControls()Updates the state of the buttons.protected voidupdateMenu()Updates the state of the menu items.protected voidupdateTitle()Updates the title of the dialog.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
SESSION_FILE
public static final String SESSION_FILE
the file to store the recent files in.- See Also:
- Constant Field Values
-
FILENAME
public static final String FILENAME
the properties file name.- See Also:
- Constant Field Values
-
EVENT_PLAY
public static final String EVENT_PLAY
- See Also:
- Constant Field Values
-
EVENT_PAUSE
public static final String EVENT_PAUSE
- See Also:
- Constant Field Values
-
EVENT_STOP
public static final String EVENT_STOP
- See Also:
- Constant Field Values
-
EVENT_MUTE
public static final String EVENT_MUTE
- See Also:
- Constant Field Values
-
DEFAULT_RATE
protected static final double DEFAULT_RATE
the values used for playback rate- See Also:
- Constant Field Values
-
MAX_RATE
protected static final double MAX_RATE
- See Also:
- Constant Field Values
-
MIN_RATE
protected static final double MIN_RATE
- See Also:
- Constant Field Values
-
RATE_STEP
protected static final double RATE_STEP
- See Also:
- Constant Field Values
-
m_Properties
protected static adams.core.Properties m_Properties
the properties to use.
-
m_MenuBar
protected JMenuBar m_MenuBar
the menu bar, if used.
-
m_MenuFileLoadRecent
protected JMenu m_MenuFileLoadRecent
the "load recent" submenu.
-
m_RecentFilesHandler
protected adams.gui.core.RecentFilesHandler<JMenu> m_RecentFilesHandler
for handling recent files.
-
m_MenuItemFileClose
protected JMenuItem m_MenuItemFileClose
the menu item "close".
-
m_MenuItemFileOpen
protected JMenuItem m_MenuItemFileOpen
the menu item "open".
-
m_FileChooser
protected adams.gui.chooser.BaseFileChooser m_FileChooser
the file chooser
-
m_MenuItemVideoShowHideControls
protected JMenuItem m_MenuItemVideoShowHideControls
the menu item "show/hide controls"
-
m_MenuItemVideoPlay
protected JMenuItem m_MenuItemVideoPlay
the menu item "play"
-
m_MenuItemVideoPause
protected JMenuItem m_MenuItemVideoPause
the menu item "pause"
-
m_MenuItemVideoStop
protected JMenuItem m_MenuItemVideoStop
the menu item "stop"
-
m_MenuItemSetSpeed
protected JMenuItem m_MenuItemSetSpeed
the menu item "Set Speed"
-
m_CurrentFile
protected File m_CurrentFile
The path to the file we're currently viewing
-
m_MediaPlayerComponent
protected DirectRenderMediaPlayerPanel m_MediaPlayerComponent
the media player component used to play video
-
m_Logger
protected adams.core.logging.Logger m_Logger
the logger used to output information to the adams console
-
m_ControlsPanel
protected adams.gui.core.BasePanel m_ControlsPanel
the panel for our video controls
-
m_SliderPosition
protected JSlider m_SliderPosition
slider for changing video position
-
m_SpinnerRate
protected JSpinner m_SpinnerRate
spinner for setting the playback rate
-
m_SpinnerModel
protected SpinnerNumberModel m_SpinnerModel
the model for our spinner
-
m_ButtonPlay
protected adams.gui.core.BaseButton m_ButtonPlay
the "play" button
-
m_ButtonPause
protected adams.gui.core.BaseButton m_ButtonPause
the "pause" button
-
m_ButtonStop
protected adams.gui.core.BaseButton m_ButtonStop
the "pause" button
-
m_ButtonMute
protected adams.gui.core.BaseButton m_ButtonMute
Mute button
-
m_TitleGenerator
protected adams.gui.core.TitleGenerator m_TitleGenerator
for generating the title.
-
m_VideoPaused
protected boolean m_VideoPaused
flag to say if video is paused
-
m_VideoLoaded
protected boolean m_VideoLoaded
flag to say if video is loaded
-
m_VLCInstalled
protected boolean m_VLCInstalled
flag to check that VLC is installed.
-
m_VideoPlaying
protected boolean m_VideoPlaying
flag for player state, playing/not playing
-
m_Executor
protected ScheduledExecutorService m_Executor
a scheduler to deal with the slider
-
m_ExecutorHandler
protected ScheduledFuture<?> m_ExecutorHandler
the handler for the scheduled event
-
m_LabelPlaybackTime
protected JLabel m_LabelPlaybackTime
label for time
-
m_LabelMediaLength
protected JLabel m_LabelMediaLength
label for the length of the current media file
-
m_PlaybackTime
protected long m_PlaybackTime
current playback time
-
m_MediaLength
protected long m_MediaLength
media length
-
m_dateFormatter
protected adams.core.DateFormat m_dateFormatter
Date formatter for outputing timestamps
-
m_PlayListeners
protected Set<ActionListener> m_PlayListeners
the listeners for the play event.
-
m_PauseListeners
protected Set<ActionListener> m_PauseListeners
the listeners for the play event.
-
m_StopListeners
protected Set<ActionListener> m_StopListeners
the listeners for the play event.
-
m_MuteListeners
protected Set<ActionListener> m_MuteListeners
the listeners for the play event.
-
-
Method Detail
-
initialize
protected void initialize()
For initializing members.- Overrides:
initializein classadams.gui.core.BasePanel
-
initGUI
public void initGUI()
For initializing the GUI.- Overrides:
initGUIin classadams.gui.core.BasePanel
-
finishInit
protected void finishInit()
finishes the initialization.- Overrides:
finishInitin classadams.gui.core.BasePanel
-
setPlaybackRate
public void setPlaybackRate(String rateString)
Sets the playback rate to the given rate- Parameters:
rateString- the playback rate (1.0 is normal speed)
-
setTitle
public void setTitle(String value)
Sets the base title to use for the title generator.- Parameters:
value- the title to use- See Also:
m_TitleGenerator
-
getTitle
public String getTitle()
Returns the base title in use by the title generator.- Returns:
- the title in use
- See Also:
m_TitleGenerator
-
getTitleGenerator
public adams.gui.core.TitleGenerator getTitleGenerator()
Returns the title generator in use.- Returns:
- the generator
-
getMenuBar
public JMenuBar getMenuBar()
Creates a menu bar (singleton per panel object). Can be used in frames.- Specified by:
getMenuBarin interfaceadams.gui.core.MenuBarProvider- Returns:
- the menu bar
-
pause
public void pause()
Pauses the video assuming there is a video loaded and playing
-
play
public void play()
Plays or stops the video depending on what state it's in currently. If there is no video loaded then nothing happens.
-
stop
public void stop()
Stops the video
-
mute
public void mute()
Mutes the video
-
unmute
public void unmute()
Unmutes the video
-
toggleMute
public void toggleMute()
Toggles the mute state.
-
enterPlaybackSpeed
public void enterPlaybackSpeed()
Updates the playback speed with the user entered value.
-
getFileChooser
protected adams.gui.chooser.BaseFileChooser getFileChooser()
Returns the file chooser to use.- Returns:
- the file chooser
-
open
public boolean open()
Pops up dialog to open a file.- Returns:
- true if video got loaded
-
open
public boolean open(File file)
Opens the specified file.- Parameters:
file- the file to open- Returns:
- true if video got loaded
-
close
protected void close()
Closes the dialog, if possible.
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceadams.core.CleanUpHandler
-
update
protected void update()
Updates title and menu items.
-
updateTitle
protected void updateTitle()
Updates the title of the dialog.
-
updateMenu
protected void updateMenu()
Updates the state of the menu items.
-
updateControls
protected void updateControls()
Updates the state of the buttons.
-
showControls
public void showControls(boolean show)
Hides or shows the control panel
-
getProperties
protected static adams.core.Properties getProperties()
Returns the properties to use for the video player.- Returns:
- the properties
-
getTimeStamp
public long getTimeStamp()
Returns the current video time in milliseconds
-
addPlayListener
public void addPlayListener(ActionListener l)
Adds the listener for the play events.- Parameters:
l- the listener to add
-
removePlayListener
public void removePlayListener(ActionListener l)
Removes the listener for the play events.- Parameters:
l- the listener to remove
-
notifyPlayListeners
protected void notifyPlayListeners()
Notifies all play listeners.
-
addPauseListener
public void addPauseListener(ActionListener l)
Adds the listener for the pause events.- Parameters:
l- the listener to add
-
removePauseListener
public void removePauseListener(ActionListener l)
Removes the listener for the pause events.- Parameters:
l- the listener to remove
-
notifyPauseListeners
protected void notifyPauseListeners()
Notifies all pause listeners.
-
addStopListener
public void addStopListener(ActionListener l)
Adds the listener for the stop events.- Parameters:
l- the listener to add
-
removeStopListener
public void removeStopListener(ActionListener l)
Removes the listener for the stop events.- Parameters:
l- the listener to remove
-
notifyStopListeners
protected void notifyStopListeners()
Notifies all stop listeners.
-
addMuteListener
public void addMuteListener(ActionListener l)
Adds the listener for the mute events.- Parameters:
l- the listener to add
-
removeMuteListener
public void removeMuteListener(ActionListener l)
Removes the listener for the mute events.- Parameters:
l- the listener to remove
-
notifyMuteListeners
protected void notifyMuteListeners()
Notifies all mute listeners.
-
getCurrentFile
public File getCurrentFile()
-
isVideoPaused
public boolean isVideoPaused()
Gets the paused status of the video- Returns:
- true if video is paused
-
isVideoLoaded
public boolean isVideoLoaded()
Gets the loaded status of the video- Returns:
- true if a media file is loaded
-
isVideoPlaying
public boolean isVideoPlaying()
Gets the playing status of the video- Returns:
- returns true if the video is currently playing
-
isVLCInstalled
public boolean isVLCInstalled()
Gets the VLC install status- Returns:
- true if VLC is installed.
-
isSoundMuted
public boolean isSoundMuted()
Gets the muted state of the sound- Returns:
- true if the sound is muted
-
-