DataLine adds media-related functionality to its
superinterface, . This functionality includes
transport-control methods that start, stop, drain, and flush
the audio data that passes through the line. A data line can also
report the current position, volume, and audio format of the media.
Data lines are used for output of audio by means of the
subinterfaces Line or
SourceDataLine, which allow an application program to write data. Similarly,
audio input is handled by the subinterface Clip,
which allows data to be read.
TargetDataLine
A data line has an internal buffer in which
the incoming or outgoing audio data is queued. The
method blocks until this internal buffer
becomes empty, usually because all queued data has been processed. The
drain() method discards any available queued data
from the internal buffer.
flush()
A data line produces and
START events whenever
it begins or ceases active presentation or capture of data. These events
can be generated in response to specific requests, or as a result of
less direct state changes. For example, if STOP is called
on an inactive data line, and data is available for capture or playback, a
start()START event will be generated shortly, when data playback
or capture actually begins. Or, if the flow of data to an active data
line is constricted so that a gap occurs in the presentation of data,
a STOP event is generated.
Mixers often support synchronized control of multiple data lines.
Synchronization can be established through the Mixer interface's
method.
See the description of the synchronize interface
for a more complete description.
Mixer
LineEvent| Nested Class Summary | |
|---|---|
static class | DataLine.Info
Besides the class information inherited from its superclass, DataLine.Info provides additional information specific to data lines. |
| Method Summary | |
|---|---|
int | available()
Obtains the number of bytes of data currently available to the application for processing in the data line's internal buffer. |
void | drain()
Drains queued data from the line by continuing data I/O until the data line's internal buffer has been emptied. |
void | flush()
Flushes queued data from the line. |
int | getBufferSize()
Obtains the maximum number of bytes of data that will fit in the data line's internal buffer. |
AudioFormat | getFormat()
Obtains the current format (encoding, sample rate, number of channels, etc.) of the data line's audio data. |
int | getFramePosition()
Obtains the current position in the audio data, in sample frames. |
float | getLevel()
Obtains the current volume level for the line. |
long | getLongFramePosition()
Obtains the current position in the audio data, in sample frames. |
long | getMicrosecondPosition()
Obtains the current position in the audio data, in microseconds. |
boolean | isActive()
Indicates whether the line is engaging in active I/O (such as playback or capture). |
boolean | isRunning()
Indicates whether the line is running. |
void | start()
Allows a line to engage in data I/O. |
void | stop()
Stops the line. |
| Methods inherited from interface javax.sound.sampled.Line |
|---|
addLineListener, close, getControl, getControls, getLineInfo, isControlSupported, isOpen, open, removeLineListener |
| Method Detail |
|---|
void drain()
drain()
is invoked on a stopped line that has data in its queue, the method will
block until the line is running and the data queue becomes empty. If
drain() is invoked by one thread, and another continues to
fill the data queue, the operation will not complete.
This method always returns when the data line is closed.
flush()void flush()
void start()
START event is generated.
stop(),
isRunning(),
LineEventvoid stop()
flush method.
When audio capture or playback stops, a STOP event is generated.
start(),
isRunning(),
flush(),
LineEventboolean isRunning()
false.
An open line begins running when the first data is presented in response to an
invocation of the start method, and continues
until presentation ceases in response to a call to stop or
because playback completes.
boolean isActive()
START event to its listeners. Similarly, when
an active line becomes inactive, it sends a
STOP event.
true if the line is actively capturing or rendering
sound, otherwise falseLine.isOpen(),
Line.addLineListener(javax.sound.sampled.LineListener),
Line.removeLineListener(javax.sound.sampled.LineListener),
LineEvent,
LineListenerAudioFormat getFormat()
If the line is not open and has never been opened, it returns
the default format. The default format is an implementation
specific audio format, or, if the DataLine.Info
object, which was used to retrieve this DataLine,
specifies at least one fully qualified audio format, the
last one will be used as the default format. Opening the
line with a specific audio format (e.g.
SourceDataLine.open(AudioFormat)) will override the
default format.
AudioFormatint getBufferSize()
int available()
Note that the units used are bytes, but will always correspond to an integral number of sample frames of audio data.
An application is guaranteed that a read or
write operation of up to the number of bytes returned from
available() will not block; however, there is no guarantee
that attempts to read or write more data will block.
int getFramePosition()
getLongFramePosition instead.
getLongFramePosition()long getLongFramePosition()
long getMicrosecondPosition()
float getLevel()
AudioSystem.NOT_SPECIFIEDCes informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
7 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)