Class UIMedia

All Implemented Interfaces:
EventListener, IMessageBox, IComponent, ICustomDataProvider, IGProp<GProp<?>[]>, IPropCnr, IUIComp, IUIContextMenuOwner, IVSComponentListener, IVSComponentState, IVSFieldListener, Cloneable
Direct Known Subclasses:
EUIMedia

public class UIMedia extends UIComp implements IUIContextMenuOwner
Media UI component.
Author:
Christopher Mindus
  • Constructor Details

    • UIMedia

      public UIMedia()
      Creates the component without a name. The name must be set in all cases using the setPropertyAtom call.
    • UIMedia

      public UIMedia(Atom propertyAtom)
      Creates the component with the specified name. All system-reserved names for components begins with "$".
      Parameters:
      propertyAtom - the name of the component, unique within it's parent.
    • UIMedia

      public UIMedia(Atom propertyAtom, GProp<?>[] newValue) throws PropException
      Creates the component with the specified name, initialized to contain the GProp items. All system-reserved names for components begins with "$".
      Parameters:
      propertyAtom - The name of the component, unique within it's parent.
      newValue - The array of all properties the component should have.
      Throws:
      PropException - when at least one of the properties to initialize the label component with is invalid.
  • Method Details

    • getAssetReferenceString

      public String getAssetReferenceString()
      Gets the current asset string.
      Returns:
      The asset reference as a string, or null for none.
    • getAssetReference

      public AssetReference getAssetReference()
      Gets the current asset reference.
      Returns:
      The asset reference, or null for none.
    • setAssetReference

      public boolean setAssetReference(String ref) throws PropException
      Sets a new asset to the media component.
      Parameters:
      ref - The media asset reference.
      Returns:
      true For success, false for no change.
      Throws:
      PropException - For property errors.
    • requestMediaInfo

      public boolean requestMediaInfo(IUIMediaListener callback)
      Request remote media player information.
      Parameters:
      callback - The callback to invoke with the information reply. Note that this is an asynchronous callback. It will not be invoked if the media player is destroyed somehow due to change of panel, client session disposal, etc.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.
      Throws:
      NullPointerException - If the callback is null.
    • play

      public boolean play()
      Sets the state of the player to PLAY mode, i.e. to start playing the media the first time, or resume from a pause.
      Returns:
      Success flag, false means this UI media component is already disposed.
    • play

      public boolean play(IUIMediaListener callback)
      Sets the state of the player to PLAY mode, i.e. to start playing the media the first time, or resume from a pause.
      Parameters:
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.
    • pause

      public boolean pause()
      Sets the state of the player to PAUSE mode.
      Returns:
      Success flag, false means this UI media component is already disposed.
    • pause

      public boolean pause(IUIMediaListener callback)
      Sets the state of the player to PAUSE mode.
      Parameters:
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.
    • load

      public boolean load()
      Requests the player to LOAD the media. Calling this method will revert the player much like to its initial state, i.e. PLAY or PAUSE will be stopped and media is reset to the beginning.
      Returns:
      Success flag, false means this UI media component is already disposed.
    • load

      public boolean load(IUIMediaListener callback)
      Requests the player to LOAD the media. Calling this method will revert the player much like to its initial state, i.e. PLAY or PAUSE will be stopped and media is reset to the beginning.
      Parameters:
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.
    • setMuted

      public boolean setMuted(boolean on)
      Sets the player's muted mode.
      Parameters:
      on - The muted state.
      Returns:
      Success flag, false means this UI media component is already disposed.

      Note that the return value is true even if the muted state already is in the requested state.

    • setMuted

      public boolean setMuted(boolean on, IUIMediaListener callback)
      Sets the player's muted mode.
      Parameters:
      on - The muted state.
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.

      Note that the return value is true even if the muted state already is in the requested state.

    • setVolume

      public boolean setVolume(int volume)
      Sets the players volume.
      Parameters:
      volume - The volume value 0-100, where 100 is full volume.
      Returns:
      Success flag, false means this UI media component is already disposed of.

      Note that the return value is true even if the volume is the same as the current volume.

      Throws:
      IllegalArgumentException - If volume is not in the range of 0-100.
    • setVolume

      public boolean setVolume(int volume, IUIMediaListener callback)
      Sets the players volume.
      Parameters:
      volume - The volume value 0-100, where 100 is full volume.
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.

      Note that the return value is true even if the volume is the same as the current volume.

      Throws:
      IllegalArgumentException - If volume is not in the range of 0-100.
    • increaseVolume

      public boolean increaseVolume()
      Increases the players volume by a step of 10.
      Returns:
      Success flag, false means this UI media component is already disposed.

      Note that the return value is true even if the volume is at its maximum.

    • increaseVolume

      public boolean increaseVolume(IUIMediaListener callback)
      Increases the players volume by a step of 10.
      Parameters:
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.

      Note that the return value is true even if the volume is at its maximum.

    • decreaseVolume

      public boolean decreaseVolume()
      Decreases the players volume by a step of 10.
      Returns:
      Success flag, false means this UI media component is already disposed.

      Note that the return value is true even if the volume is at its minimum.

    • decreaseVolume

      public boolean decreaseVolume(IUIMediaListener callback)
      Decreases the players volume by a step of 10.
      Parameters:
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.

      Note that the return value is true even if the volume is at its minimum.

    • setPosition

      public boolean setPosition(double position)
      Sets the players position in seconds.
      Parameters:
      position - The time position in seconds of the player. Note that the duration of the media limits the position that can be set, but will not generate an invalid request, so true may be returned even for very large positions after the end time of the media.
      Returns:
      Success flag, false means this UI media component is already disposed of.
      Throws:
      IllegalArgumentException - If position is negative.
    • setPosition

      public boolean setPosition(double position, IUIMediaListener callback)
      Sets the players position in seconds.
      Parameters:
      position - The time position in seconds of the player. Note that the duration of the media limits the position that can be set, but will not generate an invalid request, so true may be returned even for very large positions after the end time of the media.
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.
      Throws:
      IllegalArgumentException - If position is negative.
    • skip

      public boolean skip(double seconds)
      Skips the players position forward a number of seconds.
      Parameters:
      seconds - The number of seconds to skip forward. Note that the duration of the media limits the position that can be set, but will not generate an invalid request, so true may be returned even for very large skips after the end time of the media.
      Returns:
      Success flag, false means this UI media component is already disposed of.
      Throws:
      IllegalArgumentException - If seconds is range is not between 1 and 500.
    • skip

      public boolean skip(double seconds, IUIMediaListener callback)
      Skips the players position forward a number of seconds.
      Parameters:
      seconds - The number of seconds to skip forward. Note that the duration of the media limits the position that can be set, but will not generate an invalid request, so true may be returned even for very large skips after the end time of the media.
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.
      Throws:
      IllegalArgumentException - If seconds is range is not between 1 and 500.
    • rewind

      public boolean rewind(double seconds)
      Rewinds the players position backward a number of seconds.
      Parameters:
      seconds - The number of seconds to rewind backward. Note that the duration of the media limits the position that can be set, but will not generate an invalid request, so true may be returned even for very large rewinds and ends up at the beginning of the media.
      Returns:
      Success flag, false means this UI media component is already disposed of.
      Throws:
      IllegalArgumentException - If seconds is range is not between 1 and 500.
    • rewind

      public boolean rewind(double seconds, IUIMediaListener callback)
      Rewinds the players position backward a number of seconds.
      Parameters:
      seconds - The number of seconds to rewind backward. Note that the duration of the media limits the position that can be set, but will not generate an invalid request, so true may be returned even for very large rewinds and ends up at the beginning of the media.
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.
      Throws:
      IllegalArgumentException - If seconds is range is not between 1 and 500.
    • setPlaybackRate

      public boolean setPlaybackRate(double rate)
      Sets the playback rate factor, default being 1.
      Parameters:
      rate - The playback rate factor in the range of 0 to 100.
      Returns:
      Success flag, false means this UI media component is already disposed of.
      Throws:
      IllegalArgumentException - If rate is range is not between 0 and 100.
    • setPlaybackRate

      public boolean setPlaybackRate(double rate, IUIMediaListener callback)
      Sets the playback rate factor, default being 1.
      Parameters:
      rate - The playback rate factor in the range of 0 to 100.
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.
      Throws:
      IllegalArgumentException - If rate is range is not between 0 and 100.
    • increasePlaybackRate

      public boolean increasePlaybackRate()
      Increases the playback rate by 0.1, default rate being 1.
      Returns:
      Success flag, false means this UI media component is already disposed of.
    • increasePlaybackRate

      public boolean increasePlaybackRate(IUIMediaListener callback)
      Increases the playback rate by 0.1, default rate being 1.
      Parameters:
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.
    • decreasePlaybackRate

      public boolean decreasePlaybackRate()
      Decreases the playback rate by 0.1, default rate being 1.
      Returns:
      Success flag, false means this UI media component is already disposed of.
    • decreasePlaybackRate

      public boolean decreasePlaybackRate(IUIMediaListener callback)
      Decreases the playback rate by 0.1, default rate being 1.
      Parameters:
      callback - The callback listener, or null for none.
      Returns:
      Success flag, false means this UI media component is already disposed of and the callback would never be invoked.
    • addListener

      public boolean addListener(IUIMediaListener listener)
      Adds a media listener for client media player events.
      Parameters:
      listener - The listener to add.
      Returns:
      true if the listener was added, false otherwise (nothing changed).
      Throws:
      NullPointerException - If the listener is null.
    • removeListener

      public boolean removeListener(IUIMediaListener listener)
      Removes a listener.
      Parameters:
      listener - The listener to remove.
      Returns:
      true if listener is successfully removed, false otherwise, i.e. if not previous an added listener instance.
    • onRemoteEvent

      public void onRemoteEvent(RemoteEvent event)
      Called when a remote property event should be processed by this property.
      Specified by:
      onRemoteEvent in interface IGProp<GProp<?>[]>
      Overrides:
      onRemoteEvent in class UIComp
      Parameters:
      event - The remote event.
    • getDeviceType

      public final int getDeviceType()
      Gets the device type supported by this component: -1=mobile, 0=both, 1=desktop.
      Specified by:
      getDeviceType in interface IUIComp
    • isMobileContextMenuSupported

      public boolean isMobileContextMenuSupported()
      Returns if the component can show the context menu in mobile mode.
      Specified by:
      isMobileContextMenuSupported in interface IUIContextMenuOwner
      Returns:
      Media does not support a mobile context menu.
    • hasImplicitAlignFillX

      public boolean hasImplicitAlignFillX()
      Returns if the component has implicit component horizontal fill.
      Overrides:
      hasImplicitAlignFillX in class UIComp
      Returns:
      Always true: true means component will always fill the space in X.
    • hasImplicitAlignFillY

      public boolean hasImplicitAlignFillY()
      Returns if the component has implicit component vertical fill.
      Overrides:
      hasImplicitAlignFillY in class UIComp
      Returns:
      Always: true means component will always fill the space in Y.
    • clone

      public UIMedia clone()
      Creates a clone out of this property. The cloning is overridden by the subclasses in order to handle cloning of its class variables appropriately.

      Cloning is used for "virtualization" of a property tree in the server. Client property classes will therefore throw CloneNotSupportedException.

      Once a tree has been cloned, the change-flag is reset, and the create-flag is set. All listeners are also removed! The new cloned property is an orphan, i.e. has no parent set. All children properties are also (deep) cloned.

      Note that the cloning process is done WITHOUT thread synchronization for performance reasons, thus no modifications should be done to the tree!

      Overrides:
      clone in class UIComp
    • getApproximateSize

      public Size getApproximateSize()
      Returns the size of the component in pixels. The size is a calculation and does not exactly reflect the real size that may be different due to additional styles not taken into account by this method. The size is calculated from the font of the component and default or defined values (such as character length or number of lines for text area).
      Specified by:
      getApproximateSize in class UIComp
      Returns:
      The size of the component: 0x0 (none).