public class LineEvent extends EventObject
LineEvent类封装了线路打开,关闭,启动或停止时线路发送监听器的信息。
这四个状态变化中的每一个都由对应的事件类型表示。
侦听器接收该事件作为其update方法的参数。
通过查询事件,侦听器可以了解事件的类型,负责事件的行以及事件发生时线路处理的数据量。
虽然这个类实现了Serializable,但尝试序列化一个LineEvent对象将失败。
Line , LineListener.update(javax.sound.sampled.LineEvent)
| Modifier and Type | Class and Description |
|---|---|
static class |
LineEvent.Type
LineEvent.Type内部类标识一行发生的事件。
|
source| Constructor and Description |
|---|
LineEvent(Line line, LineEvent.Type type, long position)
构造指定类型的新事件,源自指定的行。
|
| Modifier and Type | Method and Description |
|---|---|
long |
getFramePosition()
当事件发生时,获取线路音频数据中的位置,以样本帧表示。
|
Line |
getLine()
获取作为此事件的来源的音频线。
|
LineEvent.Type |
getType()
获取事件的类型。
|
String |
toString()
获取事件的字符串表示形式。
|
getSourcepublic LineEvent(Line line, LineEvent.Type type, long position)
line - 此事件的来源
type -事件类型(
OPEN ,
CLOSE ,
START ,或
STOP )
position - 发生事件时行已经处理的样本帧数,或
AudioSystem.NOT_SPECIFIED
IllegalArgumentException - 如果
line是
null 。
public final Line getLine()
public final LineEvent.Type getType()
LineEvent.Type.OPEN ,
LineEvent.Type.CLOSE ,
LineEvent.Type.START ,或
LineEvent.Type.STOP )
public final long getFramePosition()
请注意,此字段仅与数据线生成的某些事件相关,例如START和STOP 。 对于不计算样本帧的行生成的事件,以及对于此值不知道的任何其他事件,位置值应为AudioSystem.NOT_SPECIFIED 。
public String toString()
toString在类别
EventObject
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.