Package io.guise.framework.audio
Class Audio
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- io.guise.framework.event.GuiseBoundPropertyObject
-
- io.guise.framework.platform.AbstractDepictedObject
-
- io.guise.framework.audio.Audio
-
- All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable
,com.globalmentor.beans.PropertyConstrainable
,ProgressListenable<java.lang.Long>
,DepictedObject
public class Audio extends AbstractDepictedObject implements ProgressListenable<java.lang.Long>
Audio that can be played. The installed depictor must be of the specialized typeAudio.Depictor
.- Author:
- Garret Wilson
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Audio.Depictor<A extends Audio>
The custom depictor type for audio.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AUDIO_CONTENT_TYPE_PROPERTY
The bound property of the audio content type.static java.lang.String
AUDIO_URI_PROPERTY
The bound property of the audio URI.static java.lang.String
STATE_PROPERTY
The bound property of the state.static java.lang.String
TIME_LENGTH_PROPERTY
The bound property of the play duration using microseconds.static java.lang.String
TIME_POSITION_PROPERTY
The bound property of the play position in time using microseconds.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addProgressListener(ProgressListener<java.lang.Long> progressListener)
Adds a progress listener.protected void
finalize()
protected void
fireProgressed(long timePosition, long timeDuration)
Fires a progress event to all registered progress listeners.protected void
fireProgressed(ProgressEvent<java.lang.Long> progressEvent)
Fires a given progress event to all registered progress listeners.com.globalmentor.net.ContentType
getAudioContentType()
java.net.URI
getAudioURI()
Audio.Depictor<? extends Audio>
getDepictor()
com.globalmentor.model.TaskState
getState()
long
getTimeLength()
long
getTimePosition()
void
pause()
Requests that the audio pause.void
play()
Requests that the audio start playing.void
removeProgressListener(ProgressListener<java.lang.Long> progressListener)
Removes an progress listener.void
setAudioContentType(com.globalmentor.net.ContentType newAudioContentType)
Sets the content type of the audio.void
setAudioURI(java.net.URI newAudioURI)
Sets the URI of the audio.void
setState(com.globalmentor.model.TaskState newState)
Updates the state of the audio.void
setTimePosition(long newTimePosition)
Requests a new time-based play position.void
stop()
Requests that the audio stop.protected void
updateTimeLength(long newTimeLength)
Updates the duration of the audio.protected void
updateTimePosition(long newTimePosition)
Updates the time-based play position.void
updateTimeProgress(long timePosition, long timeLength)
Updates the progress of the audio, firing the appropriate progress event.-
Methods inherited from class io.guise.framework.platform.AbstractDepictedObject
depict, equals, exportTransfer, getDepictID, getEventListenerManager, hashCode, processEvent, toString
-
Methods inherited from class io.guise.framework.event.GuiseBoundPropertyObject
getSession
-
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
Methods inherited from interface io.guise.framework.platform.DepictedObject
getSession
-
-
-
-
Field Detail
-
AUDIO_URI_PROPERTY
public static final java.lang.String AUDIO_URI_PROPERTY
The bound property of the audio URI.
-
AUDIO_CONTENT_TYPE_PROPERTY
public static final java.lang.String AUDIO_CONTENT_TYPE_PROPERTY
The bound property of the audio content type.
-
STATE_PROPERTY
public static final java.lang.String STATE_PROPERTY
The bound property of the state.
-
TIME_LENGTH_PROPERTY
public static final java.lang.String TIME_LENGTH_PROPERTY
The bound property of the play duration using microseconds.
-
TIME_POSITION_PROPERTY
public static final java.lang.String TIME_POSITION_PROPERTY
The bound property of the play position in time using microseconds.
-
-
Constructor Detail
-
Audio
public Audio()
Default constructor.
-
Audio
public Audio(java.net.URI audioURI, com.globalmentor.net.ContentType contentType)
Audio URI constructor.- Parameters:
audioURI
- The new URI of the audio, which may be a resource URI, ornull
if there is no audio URI.contentType
- The new content type of the audio, ornull
if there is no audio URI or the content type is not known.
-
-
Method Detail
-
getDepictor
public Audio.Depictor<? extends Audio> getDepictor()
- Specified by:
getDepictor
in interfaceDepictedObject
- Overrides:
getDepictor
in classAbstractDepictedObject
- Returns:
- The depictor for this object.
-
getAudioURI
public java.net.URI getAudioURI()
- Returns:
- The audio URI, which may be a resource URI, or
null
if there is no audio URI.
-
setAudioURI
public void setAudioURI(java.net.URI newAudioURI)
Sets the URI of the audio. This is a bound property of typeURI
.- Parameters:
newAudioURI
- The new URI of the audio, which may be a resource URI, ornull
if there is no audio URI.- See Also:
AUDIO_URI_PROPERTY
-
getAudioContentType
public com.globalmentor.net.ContentType getAudioContentType()
- Returns:
- The audio content type, or
null
if there is no audio URI or the content type is not known.
-
setAudioContentType
public void setAudioContentType(com.globalmentor.net.ContentType newAudioContentType)
Sets the content type of the audio. This is a bound property of typeContentType
.- Parameters:
newAudioContentType
- The new content type of the audio, ornull
if there is no audio URI or the content type is not known.- See Also:
AUDIO_CONTENT_TYPE_PROPERTY
-
getState
public com.globalmentor.model.TaskState getState()
- Returns:
- The state of the audio, or
null
if the audio has not been started.
-
setState
public void setState(com.globalmentor.model.TaskState newState)
Updates the state of the audio. This method is called by the associated depictor and should normally not be called directly by applications. This is a bound property.- Parameters:
newState
- The new state of the audio, ornull
if the audio has not been started.- See Also:
STATE_PROPERTY
-
getTimePosition
public long getTimePosition()
- Returns:
- The current play position in microseconds.
-
updateTimePosition
protected void updateTimePosition(long newTimePosition)
Updates the time-based play position. This is a bound property.- Parameters:
newTimePosition
- The new play position in microseconds.- Throws:
java.lang.IllegalArgumentException
- if the given position is negative.- See Also:
TIME_POSITION_PROPERTY
-
setTimePosition
public void setTimePosition(long newTimePosition)
Requests a new time-based play position. This is an asynchronous bound property.- Parameters:
newTimePosition
- The new play position in microseconds.- Throws:
java.lang.IllegalArgumentException
- if the given position is negative.- See Also:
TIME_POSITION_PROPERTY
-
getTimeLength
public long getTimeLength()
- Returns:
- The current duration or estimated duration in microseconds, or -1 if not known.
-
updateTimeLength
protected void updateTimeLength(long newTimeLength)
Updates the duration of the audio. This is a bound property.- Parameters:
newTimeLength
- The new duration in microseconds.- See Also:
TIME_LENGTH_PROPERTY
-
play
public void play()
Requests that the audio start playing. If the audio is currently starting to play or already playing, no action occurs.
-
pause
public void pause()
Requests that the audio pause. If the audio is not playing, no action occurs.
-
stop
public void stop()
Requests that the audio stop. If the audio is not initializing, playing, or paused, no action occurs.
-
updateTimeProgress
public void updateTimeProgress(long timePosition, long timeLength)
Updates the progress of the audio, firing the appropriate progress event. This method is called by the associated depictor and should normally not be called directly by applications.- Parameters:
timePosition
- The current play position in microseconds, or-1
if not known.timeLength
- The duration or estimated duration of the audio in microseconds, or-1
if not known.
-
addProgressListener
public void addProgressListener(ProgressListener<java.lang.Long> progressListener)
Description copied from interface:ProgressListenable
Adds a progress listener.- Specified by:
addProgressListener
in interfaceProgressListenable<java.lang.Long>
- Parameters:
progressListener
- The progress listener to add.
-
removeProgressListener
public void removeProgressListener(ProgressListener<java.lang.Long> progressListener)
Description copied from interface:ProgressListenable
Removes an progress listener.- Specified by:
removeProgressListener
in interfaceProgressListenable<java.lang.Long>
- Parameters:
progressListener
- The progress listener to remove.
-
fireProgressed
protected void fireProgressed(long timePosition, long timeDuration)
Fires a progress event to all registered progress listeners. This method delegates tofireProgressed(ProgressEvent)
.- Parameters:
timePosition
- The current position in microseconds, or-1
if not known.timeDuration
- The length or estimated length of the audio in microseconds, or-1
if not known.- See Also:
ProgressListener
,ProgressEvent
-
fireProgressed
protected void fireProgressed(ProgressEvent<java.lang.Long> progressEvent)
Fires a given progress event to all registered progress listeners.- Parameters:
progressEvent
- The progress event to fire.
-
finalize
protected void finalize() throws java.lang.Throwable
This implementation makes sure the audio is stopped.
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-