javax.sound.sampled
Class LineEvent

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject 
      extended by javax.sound.sampled.LineEvent
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable

public class LineEvent
extends EventObject sample code for java.util.EventObject definition code for 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 sample code for javax.sound.sampled.LineListener.update(javax.sound.sampled.LineEvent) definition code for javax.sound.sampled.LineListener.update(javax.sound.sampled.LineEvent) 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:
Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line , LineListener.update(javax.sound.sampled.LineEvent) sample code for javax.sound.sampled.LineListener.update(javax.sound.sampled.LineEvent) definition code for javax.sound.sampled.LineListener.update(javax.sound.sampled.LineEvent)

Nested Class Summary
static class LineEvent.Type sample code for javax.sound.sampled.LineEvent.Type definition code for javax.sound.sampled.LineEvent.Type
          The LineEvent.Type inner class identifies what kind of event occurred on a line.
 
Field Summary
 
Fields inherited from class java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject
source sample code for java.util.EventObject.source definition code for java.util.EventObject.source
 
Constructor Summary
LineEvent sample code for javax.sound.sampled.LineEvent.LineEvent(javax.sound.sampled.Line, javax.sound.sampled.LineEvent.Type, long) definition code for javax.sound.sampled.LineEvent.LineEvent(javax.sound.sampled.Line, javax.sound.sampled.LineEvent.Type, long) (Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line  line, LineEvent.Type sample code for javax.sound.sampled.LineEvent.Type definition code for javax.sound.sampled.LineEvent.Type  type, long position)
          Constructs a new event of the specified type, originating from the specified line.
 
Method Summary
 long getFramePosition sample code for javax.sound.sampled.LineEvent.getFramePosition() definition code for javax.sound.sampled.LineEvent.getFramePosition() ()
          Obtains the position in the line's audio data when the event occurred, expressed in sample frames.
 Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line getLine sample code for javax.sound.sampled.LineEvent.getLine() definition code for javax.sound.sampled.LineEvent.getLine() ()
          Obtains the audio line that is the source of this event.
 LineEvent.Type sample code for javax.sound.sampled.LineEvent.Type definition code for javax.sound.sampled.LineEvent.Type getType sample code for javax.sound.sampled.LineEvent.getType() definition code for javax.sound.sampled.LineEvent.getType() ()
          Obtains the event's type.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.sound.sampled.LineEvent.toString() definition code for javax.sound.sampled.LineEvent.toString() ()
          Obtains a string representation of the event.
 
Methods inherited from class java.util.EventObject sample code for java.util.EventObject definition code for java.util.EventObject
getSource sample code for java.util.EventObject.getSource() definition code for java.util.EventObject.getSource()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

LineEvent sample code for javax.sound.sampled.LineEvent(javax.sound.sampled.Line, javax.sound.sampled.LineEvent.Type, long) definition code for javax.sound.sampled.LineEvent(javax.sound.sampled.Line, javax.sound.sampled.LineEvent.Type, long)

public LineEvent(Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line  line,
                 LineEvent.Type sample code for javax.sound.sampled.LineEvent.Type definition code for javax.sound.sampled.LineEvent.Type  type,
                 long position)
Constructs a new event of the specified type, originating from the specified line.

Parameters:
line - the source of this event
type - 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 sample code for javax.sound.sampled.AudioSystem.NOT_SPECIFIED definition code for javax.sound.sampled.AudioSystem.NOT_SPECIFIED
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if line is null.
Method Detail

getLine sample code for javax.sound.sampled.LineEvent.getLine() definition code for javax.sound.sampled.LineEvent.getLine()

public final Line sample code for javax.sound.sampled.Line definition code for javax.sound.sampled.Line  getLine()
Obtains the audio line that is the source of this event.

Returns:
the line responsible for this event

getType sample code for javax.sound.sampled.LineEvent.getType() definition code for javax.sound.sampled.LineEvent.getType()

public final LineEvent.Type sample code for javax.sound.sampled.LineEvent.Type definition code for javax.sound.sampled.LineEvent.Type  getType()
Obtains the event's type.

Returns:
this event's type (LineEvent.Type.OPEN sample code for javax.sound.sampled.LineEvent.Type.OPEN definition code for javax.sound.sampled.LineEvent.Type.OPEN , LineEvent.Type.CLOSE sample code for javax.sound.sampled.LineEvent.Type.CLOSE definition code for javax.sound.sampled.LineEvent.Type.CLOSE , LineEvent.Type.START sample code for javax.sound.sampled.LineEvent.Type.START definition code for javax.sound.sampled.LineEvent.Type.START , or LineEvent.Type.STOP sample code for javax.sound.sampled.LineEvent.Type.STOP definition code for javax.sound.sampled.LineEvent.Type.STOP )

getFramePosition sample code for javax.sound.sampled.LineEvent.getFramePosition() definition code for javax.sound.sampled.LineEvent.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 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 sample code for javax.sound.sampled.AudioSystem.NOT_SPECIFIED definition code for javax.sound.sampled.AudioSystem.NOT_SPECIFIED .

Returns:
the line's position as a sample frame number

toString sample code for javax.sound.sampled.LineEvent.toString() definition code for javax.sound.sampled.LineEvent.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Obtains a string representation of the event. The contents of the string may vary between implementations of Java Sound.

Overrides:
toString sample code for java.util.EventObject.toString() definition code for java.util.EventObject.toString() in class EventObject sample code for java.util.EventObject definition code for java.util.EventObject
Returns:
a string describing the event.