APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.sound.sampled

public Class LineEvent

extends EventObject
Class Inheritance
Imports
java.io.Serial, java.util.EventObject

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.

Author
Kara Kytle
Since
1.3
See Also
Line, LineListener#update

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
LineEvent.Type

The LineEvent.Type inner class identifies what kind of event occurred on a line.

Field Summary

Modifier and TypeField and Description
private final long
position

The media position when the event occurred, expressed in sample frames.

private static final long
serialVersionUID

Hides java.util.EventObject.serialVersionUID.

Use serialVersionUID from JDK 1.3 for interoperability.
private final LineEvent.Type
type

The kind of line event (OPEN, CLOSE, START, or STOP).

Inherited from java.util.EventObject:
source

Constructor Summary

AccessConstructor and Description
public
LineEvent(Line
the source of this event
line
,
LineEvent.Type
the event type (OPEN, CLOSE, START, or STOP)
type
,
long
the number of sample frames that the line had already processed when the event occurred, or AudioSystem#NOT_SPECIFIED
position
)

Constructs a new event of the specified type, originating from the specified line.

Method Summary

Modifier and TypeMethod and Description
public final long

Returns:

the line's position as a sample frame number
getFramePosition
()

Obtains the position in the line's audio data when the event occurred, expressed in sample frames.

public final Line

Returns:

the line responsible for this event
getLine
()

Obtains the audio line that is the source of this event.

public final LineEvent.Type

Returns:

this event's type (Type#OPEN, Type#CLOSE, Type#START, or Type#STOP)
getType
()

Obtains the event's type.

public String

Returns:

a string representation of the event
toString
()

Overrides java.util.EventObject.toString.

Returns a string representation of the event.

Inherited from java.util.EventObject:
getSource

Field Detail

positionback to summary
private final long position

The media position when the event occurred, expressed in sample frames. Note that this field is only relevant 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.

See Also
getFramePosition
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.EventObject.serialVersionUID.

Use serialVersionUID from JDK 1.3 for interoperability.

Annotations
@Serial
typeback to summary
private final LineEvent.Type type

The kind of line event (OPEN, CLOSE, START, or STOP).

Annotations
@SuppressWarnings:serial
See Also
getType

Constructor Detail

LineEventback to summary
public LineEvent(Line line, LineEvent.Type type, long position)

Constructs a new event of the specified type, originating from the specified line.

Parameters
line:Line

the source of this event

type:LineEvent.Type

the event type (OPEN, CLOSE, START, or STOP)

position:long

the number of sample frames that the line had already processed when the event occurred, or AudioSystem#NOT_SPECIFIED

Exceptions
IllegalArgumentException:
if line is null

Method Detail

getFramePositionback to summary
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 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.

Returns:long

the line's position as a sample frame number

getLineback to summary
public final Line getLine()

Obtains the audio line that is the source of this event.

Returns:Line

the line responsible for this event

getTypeback to summary
public final LineEvent.Type getType()

Obtains the event's type.

Returns:LineEvent.Type

this event's type (Type#OPEN, Type#CLOSE, Type#START, or Type#STOP)

toStringback to summary
public String toString()

Overrides java.util.EventObject.toString.

Returns a string representation of the event.

Returns:String

a string representation of the event

Annotations
@Override
javax.sound.sampled back to summary

public Class LineEvent.Type

extends Object
Class Inheritance

The LineEvent.Type inner class identifies what kind of event occurred on a line. Static instances are provided for the common types (OPEN, CLOSE, START, and STOP).
See Also
LineEvent#getType()

Field Summary

Modifier and TypeField and Description
public static final LineEvent.Type
CLOSE

A type of event that is sent when a line closes, freeing the system resources it had obtained when it was opened.

private final String
name

Type name.

public static final LineEvent.Type
OPEN

A type of event that is sent when a line opens, reserving system resources for itself.

public static final LineEvent.Type
START

A type of event that is sent when a line begins to engage in active input or output of audio data in response to a start request.

public static final LineEvent.Type
STOP

A type of event that is sent when a line ceases active input or output of audio data in response to a stop request, or because the end of media has been reached.

Constructor Summary

AccessConstructor and Description
protected
Type(String
name of the type
name
)

Constructs a new event type.

Method Summary

Modifier and TypeMethod and Description
public final boolean

Returns:

true if the specified object is equal to this event type; false otherwise
equals
(Object
the reference object with which to compare
obj
)

Overrides java.lang.Object.equals.

Indicates whether the specified object is equal to this event type, returning true if the objects are the same.

public final int

Returns:

a hash code value for this event type
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this event type.

public String

Returns:

a string representation of the event type
toString
()

Overrides java.lang.Object.toString.

Returns type's name as the string representation of the event type.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

CLOSEback to summary
public static final LineEvent.Type CLOSE

A type of event that is sent when a line closes, freeing the system resources it had obtained when it was opened.

See Also
OPEN, Line#close
nameback to summary
private final String name

Type name.

OPENback to summary
public static final LineEvent.Type OPEN

A type of event that is sent when a line opens, reserving system resources for itself.

See Also
CLOSE, Line#open
STARTback to summary
public static final LineEvent.Type START

A type of event that is sent when a line begins to engage in active input or output of audio data in response to a start request.

See Also
STOP, DataLine#start
STOPback to summary
public static final LineEvent.Type STOP

A type of event that is sent when a line ceases active input or output of audio data in response to a stop request, or because the end of media has been reached.

See Also
START, DataLine#stop

Constructor Detail

Typeback to summary
protected Type(String name)

Constructs a new event type.

Parameters
name:String

name of the type

Method Detail

equalsback to summary
public final boolean equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether the specified object is equal to this event type, returning true if the objects are the same.

Parameters
obj:Object

the reference object with which to compare

Returns:boolean

true if the specified object is equal to this event type; false otherwise

Annotations
@Override
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this event type.

Returns:int

a hash code value for this event type

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns type's name as the string representation of the event type.

Returns:String

a string representation of the event type

Annotations
@Override