FileDocCategorySizeDatePackage
LineEvent.javaAPI DocJava SE 5 API7817Fri Aug 26 14:57:50 BST 2005javax.sound.sampled

LineEvent

public class LineEvent extends 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 {@link LineListener#update 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
version
1.26, 03/12/19
see
Line
see
LineListener#update
since
1.3
serial
exclude

Fields Summary
private final Type
type
The kind of line event (OPEN, CLOSE, START, or STOP).
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 {@link AudioSystem#NOT_SPECIFIED}.
Constructors Summary
public LineEvent(Line line, Type type, long position)
Constructs a new event of the specified type, originating from the specified line.

param
line the source of this event
param
type the event type (OPEN, CLOSE, START, or STOP)
param
position the number of sample frames that the line had already processed when the event occurred, or {@link AudioSystem#NOT_SPECIFIED}
throws
IllegalArgumentException if line is null.


	super(line);
	this.type = type; 
	this.position = position;
    
Methods Summary
public final longgetFramePosition()
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 {@link AudioSystem#NOT_SPECIFIED}.

return
the line's position as a sample frame number


	return position;
    
public final javax.sound.sampled.LinegetLine()
Obtains the audio line that is the source of this event.

return
the line responsible for this event


	return (Line)getSource();
    
public final javax.sound.sampled.LineEvent$TypegetType()
Obtains the event's type.

return
this event's type ({@link Type#OPEN}, {@link Type#CLOSE}, {@link Type#START}, or {@link Type#STOP})


	return type;
    
public java.lang.StringtoString()
Obtains a string representation of the event. The contents of the string may vary between implementations of Java Sound.

return
a string describing the event.

	String sType = "";
	if (type != null) sType = type.toString()+" ";
	String sLine;
	if (getLine() == null) {
	    sLine = "null";
	} else {
	    sLine = getLine().toString();
	}
	return new String(sType + "event from line " + sLine);