|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QSound
public class QSound
The QSound class provides access to the platform audio facilities. Qt provides the most commonly required audio operation in GUI applications: asynchronously playing a sound file. This is most easily accomplished using the static play()
function:
QSound.play("mysounds/bells.wav");Alternatively, create a QSound object from the sound file first and then call the
play()
slot: QSound bells = new QSound("mysounds/bells.wav"); bells.play();Once created a QSound object can be queried for its
fileName()
and total number of loops()
(i.e. the number of times the sound will play). The number of repetitions can be altered using the setLoops()
function. While playing the sound, the loopsRemaining()
function returns the remaining number of repetitions. Use the isFinished()
function to determine whether the sound has finished playing. Sounds played using a QSound object may use more memory than the static play()
function, but it may also play more immediately (depending on the underlying platform audio facilities). Use the static isAvailable()
function to determine whether sound facilities exist on the platform. Which facilities that are actually used varies:
Microsoft Windows | The underlying multimedia system is used; only WAVE format sound files are supported. |
X11 | The Network Audio System is used if available, otherwise all operations work silently. NAS supports WAVE and AU files. |
Mac OS X | NSSound is used. All formats that NSSound supports, including QuickTime formats, are supported by Qt for Mac OS X. |
Qt for Embedded Linux | A built-in mixing sound server is used, accessing /dev/dsp directly. Only the WAVE format is supported. |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QSound(java.lang.String filename)
Constructs a QSound object from the file specified by the given filename and with the given parent. |
|
QSound(java.lang.String filename,
QObject parent)
Constructs a QSound object from the file specified by the given filename and with the given parent. |
Method Summary | |
---|---|
java.lang.String |
fileName()
Returns the filename associated with this QSound object. |
static boolean |
isAvailable()
Returns true if sound facilities exist on the platform; otherwise returns false. |
boolean |
isFinished()
Returns true if the sound has finished playing; otherwise returns false. |
int |
loops()
Returns the number of times the sound will play. |
int |
loopsRemaining()
Returns the remaining number of times the sound will loop (this value decreases each time the sound is played). |
void |
play()
Starts playing the sound specified by this QSound object. |
static void |
play(java.lang.String filename)
Plays the sound stored in the file specified by the given filename. |
void |
setLoops(int arg__1)
Sets the sound to repeat the given number of times when it is played. |
void |
stop()
Stops the sound playing. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QSound(java.lang.String filename)
This may use more memory than the static play()
function, but it may also play more immediately (depending on the underlying platform audio facilities).
play()
.
public QSound(java.lang.String filename, QObject parent)
This may use more memory than the static play()
function, but it may also play more immediately (depending on the underlying platform audio facilities).
play()
.
Method Detail |
---|
public final java.lang.String fileName()
public final boolean isFinished()
Warning: On Windows this function always returns true for unlooped sounds.
public final int loops()
loopsRemaining()
, and setLoops()
.
public final int loopsRemaining()
loops()
, and isFinished()
.
public final void play()
The function returns immediately. Depending on the platform audio facilities, other sounds may stop or be mixed with the new sound. The sound can be played again at any time, possibly mixing or replacing previous plays of the sound.
fileName()
.
public final void setLoops(int arg__1)
Note that passing the value -1 will cause the sound to loop indefinitely.
loops()
.
public final void stop()
Note that on Windows the current loop will finish if a sound is played in a loop.
play()
.
public static boolean isAvailable()
If no sound is available, all QSound operations work silently and quickly. An application may choose either to notify the user if sound is crucial to the application or to operate silently without bothering the user.
Note: On Windows this always returns true because some sound card drivers do not implement a way to find out whether it is available or not.
public static void play(java.lang.String filename)
stop()
, loopsRemaining()
, and isFinished()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |