1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qsound.cpp:97 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QSound Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QSound Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QSound class provides access to the platform audio facilities.
|
---|
35 | <a href="#details">More...</a>
|
---|
36 | <p><tt>#include <<a href="qsound-h.html">qsound.h</a>></tt>
|
---|
37 | <p>Inherits <a href="qobject.html">QObject</a>.
|
---|
38 | <p><a href="qsound-members.html">List of all member functions.</a>
|
---|
39 | <h2>Public Members</h2>
|
---|
40 | <ul>
|
---|
41 | <li class=fn><a href="#QSound"><b>QSound</b></a> ( const QString & filename, QObject * parent = 0, const char * name = 0 )</li>
|
---|
42 | <li class=fn><a href="#~QSound"><b>~QSound</b></a> ()</li>
|
---|
43 | <li class=fn>int <a href="#loops"><b>loops</b></a> () const</li>
|
---|
44 | <li class=fn>int <a href="#loopsRemaining"><b>loopsRemaining</b></a> () const</li>
|
---|
45 | <li class=fn>void <a href="#setLoops"><b>setLoops</b></a> ( int l )</li>
|
---|
46 | <li class=fn>QString <a href="#fileName"><b>fileName</b></a> () const</li>
|
---|
47 | <li class=fn>bool <a href="#isFinished"><b>isFinished</b></a> () const</li>
|
---|
48 | </ul>
|
---|
49 | <h2>Public Slots</h2>
|
---|
50 | <ul>
|
---|
51 | <li class=fn>void <a href="#play-2"><b>play</b></a> ()</li>
|
---|
52 | <li class=fn>void <a href="#stop"><b>stop</b></a> ()</li>
|
---|
53 | </ul>
|
---|
54 | <h2>Static Public Members</h2>
|
---|
55 | <ul>
|
---|
56 | <li class=fn>bool <a href="#isAvailable"><b>isAvailable</b></a> ()</li>
|
---|
57 | <li class=fn>void <a href="#play"><b>play</b></a> ( const QString & filename )</li>
|
---|
58 | <li class=fn>bool <a href="#available"><b>available</b></a> ()</li>
|
---|
59 | </ul>
|
---|
60 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
61 |
|
---|
62 |
|
---|
63 | The QSound class provides access to the platform audio facilities.
|
---|
64 | <p>
|
---|
65 |
|
---|
66 | <p> Qt provides the most commonly required audio operation in GUI
|
---|
67 | applications: asynchronously playing a sound file. This is most
|
---|
68 | easily accomplished with a single call:
|
---|
69 | <pre>
|
---|
70 | QSound::<a href="#play">play</a>("mysounds/bells.wav");
|
---|
71 | </pre>
|
---|
72 |
|
---|
73 | <p> A second API is provided in which a QSound object is created from
|
---|
74 | a sound file and is played later:
|
---|
75 | <pre>
|
---|
76 | QSound bells("mysounds/bells.wav");
|
---|
77 |
|
---|
78 | bells.<a href="#play">play</a>();
|
---|
79 | </pre>
|
---|
80 |
|
---|
81 | <p> Sounds played using the second model may use more memory but play
|
---|
82 | more immediately than sounds played using the first model,
|
---|
83 | depending on the underlying platform audio facilities.
|
---|
84 | <p> On Microsoft Windows the underlying multimedia system is used;
|
---|
85 | only WAVE format sound files are supported.
|
---|
86 | <p> On X11 the <a href="ftp://ftp.x.org/contrib/audio/nas/">Network Audio
|
---|
87 | System</a> is used if available, otherwise all operations work
|
---|
88 | silently. NAS supports WAVE and AU files.
|
---|
89 | <p> On Macintosh, ironically, we use QT (<a href="http://quicktime.apple.com">QuickTime</a>) for sound, this
|
---|
90 | means all QuickTime formats are supported by Qt/Mac.
|
---|
91 | <p> On Qt/Embedded, a built-in mixing sound server is used, which
|
---|
92 | accesses <tt>/dev/dsp</tt> directly. Only the WAVE format is supported.
|
---|
93 | <p> The availability of sound can be tested with
|
---|
94 | <a href="#isAvailable">QSound::isAvailable</a>().
|
---|
95 | <p>See also <a href="multimedia.html">Multimedia Classes</a>.
|
---|
96 |
|
---|
97 | <hr><h2>Member Function Documentation</h2>
|
---|
98 | <h3 class=fn><a name="QSound"></a>QSound::QSound ( const <a href="qstring.html">QString</a> & filename, <a href="qobject.html">QObject</a> * parent = 0, const char * name = 0 )
|
---|
99 | </h3>
|
---|
100 | Constructs a QSound that can quickly play the sound in a file
|
---|
101 | named <em>filename</em>.
|
---|
102 | <p> This may use more memory than the static <tt>play</tt> function.
|
---|
103 | <p> The <em>parent</em> and <em>name</em> arguments (default 0) are passed on to
|
---|
104 | the <a href="qobject.html">QObject</a> constructor.
|
---|
105 |
|
---|
106 | <h3 class=fn><a name="~QSound"></a>QSound::~QSound ()
|
---|
107 | </h3>
|
---|
108 | Destroys the sound object. If the sound is not finished playing <a href="#stop">stop</a>() is called on it.
|
---|
109 | <p> <p>See also <a href="#stop">stop</a>() and <a href="#isFinished">isFinished</a>().
|
---|
110 |
|
---|
111 | <h3 class=fn>bool <a name="available"></a>QSound::available ()<tt> [static]</tt>
|
---|
112 | </h3>
|
---|
113 |
|
---|
114 | <p> Returns TRUE if sound support is available; otherwise returns FALSE.
|
---|
115 |
|
---|
116 | <h3 class=fn><a href="qstring.html">QString</a> <a name="fileName"></a>QSound::fileName () const
|
---|
117 | </h3>
|
---|
118 | Returns the filename associated with the sound.
|
---|
119 |
|
---|
120 | <h3 class=fn>bool <a name="isAvailable"></a>QSound::isAvailable ()<tt> [static]</tt>
|
---|
121 | </h3>
|
---|
122 | Returns TRUE if sound facilities exist on the platform; otherwise
|
---|
123 | returns FALSE. An application may choose either to notify the user
|
---|
124 | if sound is crucial to the application or to operate silently
|
---|
125 | without bothering the user.
|
---|
126 | <p> If no sound is available, all QSound operations work silently and
|
---|
127 | quickly.
|
---|
128 |
|
---|
129 | <h3 class=fn>bool <a name="isFinished"></a>QSound::isFinished () const
|
---|
130 | </h3>
|
---|
131 | Returns TRUE if the sound has finished playing; otherwise returns FALSE.
|
---|
132 | <p> <b>Warning:</b> On Windows this function always returns TRUE for unlooped sounds.
|
---|
133 |
|
---|
134 | <h3 class=fn>int <a name="loops"></a>QSound::loops () const
|
---|
135 | </h3>
|
---|
136 | Returns the number of times the sound will play.
|
---|
137 |
|
---|
138 | <h3 class=fn>int <a name="loopsRemaining"></a>QSound::loopsRemaining () const
|
---|
139 | </h3>
|
---|
140 | Returns the number of times the sound will loop. This value
|
---|
141 | decreases each time the sound loops.
|
---|
142 |
|
---|
143 | <h3 class=fn>void <a name="play"></a>QSound::play ( const <a href="qstring.html">QString</a> & filename )<tt> [static]</tt>
|
---|
144 | </h3>
|
---|
145 | Plays the sound in a file called <em>filename</em>.
|
---|
146 |
|
---|
147 | <p>Example: <a href="sound-example.html#x2813">sound/sound.cpp</a>.
|
---|
148 | <h3 class=fn>void <a name="play-2"></a>QSound::play ()<tt> [slot]</tt>
|
---|
149 | </h3>
|
---|
150 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
151 | <p> Starts the sound playing. The function returns immediately.
|
---|
152 | Depending on the platform audio facilities, other sounds may stop
|
---|
153 | or may be mixed with the new sound.
|
---|
154 | <p> The sound can be played again at any time, possibly mixing or
|
---|
155 | replacing previous plays of the sound.
|
---|
156 |
|
---|
157 | <h3 class=fn>void <a name="setLoops"></a>QSound::setLoops ( int l )
|
---|
158 | </h3>
|
---|
159 | Sets the sound to repeat <em>l</em> times when it is played. Passing the
|
---|
160 | value -1 will cause the sound to loop indefinitely.
|
---|
161 | <p> <p>See also <a href="#loops">loops</a>().
|
---|
162 |
|
---|
163 | <h3 class=fn>void <a name="stop"></a>QSound::stop ()<tt> [slot]</tt>
|
---|
164 | </h3>
|
---|
165 | Stops the sound playing.
|
---|
166 | <p> On Windows the current loop will finish if a sound is played
|
---|
167 | in a loop.
|
---|
168 | <p> <p>See also <a href="#play">play</a>().
|
---|
169 |
|
---|
170 | <!-- eof -->
|
---|
171 | <hr><p>
|
---|
172 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
173 | Copyright © 1995-2007
|
---|
174 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
175 | <table width=100% cellspacing=0 border=0><tr>
|
---|
176 | <td>Copyright © 2007
|
---|
177 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
178 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
179 | </table></div></address></body>
|
---|
180 | </html>
|
---|