Class LineEvent
java.lang.Object
java.util.EventObject
javax.sound.sampled.LineEvent
- All Implemented Interfaces:
Serializable
The
LineEvent class encapsulates information that a line sends its
listeners whenever the line opens, closes, starts, or stops. Each of these
four state changes is represented by a corresponding type of event. A
listener receives the event as a parameter to its
update method. By querying the event, the
listener can learn the type of event, the line responsible for the event, and
how much data the line had processed when the event occurred.
Although this class implements Serializable, attempts to serialize a
LineEvent object will fail.
- Since:
- 1.3
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe LineEvent.Type inner class identifies what kind of event occurred on a line. -
Field Summary
Fields declared in class EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionLineEvent(Line line, LineEvent.Type type, long position) Constructs a new event of the specified type, originating from the specified line. -
Method Summary
Modifier and TypeMethodDescriptionfinal longObtains the position in the line's audio data when the event occurred, expressed in sample frames.final LinegetLine()Obtains the audio line that is the source of this event.final LineEvent.TypegetType()Obtains the event's type.toString()Returns a string representation of the event.Methods declared in class EventObject
getSourceMethods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
LineEvent
Constructs a new event of the specified type, originating from the specified line.- Parameters:
line- the source of this eventtype- the event type (OPEN,CLOSE,START, orSTOP)position- the number of sample frames that the line had already processed when the event occurred, orAudioSystem.NOT_SPECIFIED- Throws:
IllegalArgumentException- iflineisnull
-
-
Method Details
-
getLine
Obtains the audio line that is the source of this event.- Returns:
- the line responsible for this event
-
getType
Obtains the event's type.- Returns:
- this event's type (
LineEvent.Type.OPEN,LineEvent.Type.CLOSE,LineEvent.Type.START, orLineEvent.Type.STOP)
-
getFramePosition
public final long getFramePosition()Obtains the position in the line's audio data when the event occurred, expressed in sample frames. For example, if a source line had already played back 14 sample frames at the time it was paused, the pause event would report the line's position as 14. The next frame to be processed would be frame number 14 using zero-based numbering, or 15 using one-based numbering.Note that this field is relevant only to certain events generated by data lines, such as
STARTandSTOP. For events generated by lines that do not count sample frames, and for any other events for which this value is not known, the position value should beAudioSystem.NOT_SPECIFIED.- Returns:
- the line's position as a sample frame number
-
toString
Returns a string representation of the event.- Overrides:
toStringin classEventObject- Returns:
- a string representation of the event
-