Serializable
public class LineEvent extends EventObject
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.
Modifier and Type | Class | Description |
---|---|---|
static class |
LineEvent.Type |
The LineEvent.Type inner class identifies what kind of event occurred on a line. |
source
Constructor | Description |
---|---|
LineEvent |
Constructs a new event of the specified type, originating from the specified line. |
Modifier and Type | Method | Description |
---|---|---|
final long |
getFramePosition() |
Obtains the position in the line's audio data when the event occurred, expressed in sample frames. |
final Line |
getLine() |
Obtains the audio line that is the source of this event. |
final LineEvent.Type |
getType() |
Obtains the event's type. |
String |
toString() |
Returns a string representation of the event. |
getSource
public LineEvent(Line line, LineEvent.Type type, long position)
line
- the source of this eventtype
- the event type (OPEN
, CLOSE
, START
, or STOP
)position
- the number of sample frames that the line had already processed when the event occurred, or AudioSystem.NOT_SPECIFIED
IllegalArgumentException
- if line
is null
public final Line getLine()
public final LineEvent.Type getType()
LineEvent.Type.OPEN
, LineEvent.Type.CLOSE
, LineEvent.Type.START
, or LineEvent.Type.STOP
)public final long getFramePosition()
Note that this field is relevant only to certain events generated by data lines, such as START
and STOP
. 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 be AudioSystem.NOT_SPECIFIED
.
public String toString()
toString
in class EventObject
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/sound/sampled/LineEvent.html