Sophie

Sophie

distrib > Mageia > 6 > armv5tl > by-pkgid > 9ee5ef51dbf4a00567f58cff4d0e160c > files > 299

qtmultimedia5-doc-5.9.4-1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qsound.cpp -->
  <title>QSound Class | Qt Multimedia 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtmultimedia-index.html">Qt Multimedia</a></td><td ><a href="qtmultimedia-modules.html">C++ Classes</a></td><td >QSound</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QSound Class</h1>
<!-- $$$QSound-brief -->
<p>The <a href="qsound.html">QSound</a> class provides a method to play .wav sound files. <a href="#details">More...</a></p>
<!-- @@@QSound -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QSound&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += multimedia</td></tr></table></div><ul>
<li><a href="qsound-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#Loop-enum">Loop</a></b> { Infinite }</td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#QSound">QSound</a></b>(const QString &amp;<i>filename</i>, QObject *<i>parent</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#dtor.QSound">~QSound</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#fileName">fileName</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#isFinished">isFinished</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#loops">loops</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#loopsRemaining">loopsRemaining</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#setLoops">setLoops</a></b>(int <i>number</i>)</td></tr>
</table></div>
<a name="public-slots"></a>
<h2 id="public-slots">Public Slots</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#play-1">play</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#stop">stop</a></b>()</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsound.html#play">play</a></b>(const QString &amp;<i>filename</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QSound-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qsound.html">QSound</a> class provides a method to play .wav sound files.</p>
<p>Qt provides the most commonly required audio operation in GUI applications: asynchronously playing a sound file. This is most easily accomplished using the static <a href="qsound.html#play-1">play</a>() function:</p>
<pre class="cpp">

  <span class="type"><a href="qsound.html#QSound">QSound</a></span><span class="operator">::</span>play(<span class="string">&quot;mysounds/bells.wav&quot;</span>);

</pre>
<p>Alternatively, create a <a href="qsound.html">QSound</a> object from the sound file first and then call the <a href="qsound.html#play-1">play</a>() slot:</p>
<pre class="cpp">

  <span class="type"><a href="qsound.html#QSound">QSound</a></span> bells(<span class="string">&quot;mysounds/bells.wav&quot;</span>);
  bells<span class="operator">.</span>play();

</pre>
<p>Once created a <a href="qsound.html">QSound</a> object can be queried for its <a href="qsound.html#fileName">fileName</a>() and total number of <a href="qsound.html#loops">loops</a>() (i.e&#x2e; the number of times the sound will play). The number of repetitions can be altered using the <a href="qsound.html#setLoops">setLoops</a>() function. While playing the sound, the <a href="qsound.html#loopsRemaining">loopsRemaining</a>() function returns the remaining number of repetitions. Use the <a href="qsound.html#isFinished">isFinished</a>() function to determine whether the sound has finished playing.</p>
<p>Sounds played using a <a href="qsound.html">QSound</a> object may use more memory than the static <a href="qsound.html#play-1">play</a>() function, but it may also play more immediately (depending on the underlying platform audio facilities).</p>
<p>If you require finer control over playing sounds, consider the <a href="qsoundeffect.html">QSoundEffect</a> or <a href="qaudiooutput.html">QAudioOutput</a> classes.</p>
</div>
<p><b>See also </b><a href="qsoundeffect.html">QSoundEffect</a>.</p>
<!-- @@@QSound -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$Loop$$$Infinite -->
<h3 class="fn" id="Loop-enum"><a name="Loop-enum"></a>enum QSound::<span class="name">Loop</span></h3>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QSound::Infinite</code></td><td class="topAlign tblval"><code>-1</code></td><td class="topAlign">Can be used as a parameter to <a href="qsound.html#setLoops">setLoops</a>() to loop infinitely.</td></tr>
</table></div>
<!-- @@@Loop -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QSound[overload1]$$$QSoundconstQString&QObject* -->
<h3 class="fn" id="QSound"><a name="QSound"></a>QSound::<span class="name">QSound</span>(const <span class="type">QString</span> &amp;<i>filename</i>, <span class="type">QObject</span> *<i>parent</i> = Q_NULLPTR)</h3>
<p>Constructs a <a href="qsound.html">QSound</a> object from the file specified by the given <i>filename</i> and with the given <i>parent</i>.</p>
<p><b>See also </b><a href="qsound.html#play-1">play</a>().</p>
<!-- @@@QSound -->
<!-- $$$~QSound[overload1]$$$~QSound -->
<h3 class="fn" id="dtor.QSound"><a name="dtor.QSound"></a>QSound::<span class="name">~QSound</span>()</h3>
<p>Destroys this sound object. If the sound is not finished playing, the <a href="qsound.html#stop">stop</a>() function is called before the sound object is destroyed.</p>
<p><b>See also </b><a href="qsound.html#stop">stop</a>() and <a href="qsound.html#isFinished">isFinished</a>().</p>
<!-- @@@~QSound -->
<!-- $$$fileName[overload1]$$$fileName -->
<h3 class="fn" id="fileName"><a name="fileName"></a><span class="type">QString</span> QSound::<span class="name">fileName</span>() const</h3>
<p>Returns the filename associated with this <a href="qsound.html">QSound</a> object.</p>
<p><b>See also </b><a href="qsound.html#QSound">QSound</a>().</p>
<!-- @@@fileName -->
<!-- $$$isFinished[overload1]$$$isFinished -->
<h3 class="fn" id="isFinished"><a name="isFinished"></a><span class="type">bool</span> QSound::<span class="name">isFinished</span>() const</h3>
<p>Returns true if the sound has finished playing; otherwise returns false.</p>
<!-- @@@isFinished -->
<!-- $$$loops[overload1]$$$loops -->
<h3 class="fn" id="loops"><a name="loops"></a><span class="type">int</span> QSound::<span class="name">loops</span>() const</h3>
<p>Returns the number of times the sound will play. Return value of <code>QSound::Infinite</code> indicates infinite number of loops</p>
<p><b>See also </b><a href="qsound.html#loopsRemaining">loopsRemaining</a>() and <a href="qsound.html#setLoops">setLoops</a>().</p>
<!-- @@@loops -->
<!-- $$$loopsRemaining[overload1]$$$loopsRemaining -->
<h3 class="fn" id="loopsRemaining"><a name="loopsRemaining"></a><span class="type">int</span> QSound::<span class="name">loopsRemaining</span>() const</h3>
<p>Returns the remaining number of times the sound will loop (for all positive values this value decreases each time the sound is played). Return value of <code>QSound::Infinite</code> indicates infinite number of loops</p>
<p><b>See also </b><a href="qsound.html#loops">loops</a>() and <a href="qsound.html#isFinished">isFinished</a>().</p>
<!-- @@@loopsRemaining -->
<!-- $$$play[overload1]$$$playconstQString& -->
<h3 class="fn" id="play"><a name="play"></a><code>[static] </code><span class="type">void</span> QSound::<span class="name">play</span>(const <span class="type">QString</span> &amp;<i>filename</i>)</h3>
<p>Plays the sound stored in the file specified by the given <i>filename</i>.</p>
<p><b>See also </b><a href="qsound.html#stop">stop</a>(), <a href="qsound.html#loopsRemaining">loopsRemaining</a>(), and <a href="qsound.html#isFinished">isFinished</a>().</p>
<!-- @@@play -->
<!-- $$$play$$$play -->
<h3 class="fn" id="play-1"><a name="play-1"></a><code>[slot] </code><span class="type">void</span> QSound::<span class="name">play</span>()</h3>
<p>This is an overloaded function.</p>
<p>Starts playing the sound specified by this <a href="qsound.html">QSound</a> object.</p>
<p>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.</p>
<p><b>See also </b><a href="qsound.html#fileName">fileName</a>().</p>
<!-- @@@play -->
<!-- $$$setLoops[overload1]$$$setLoopsint -->
<h3 class="fn" id="setLoops"><a name="setLoops"></a><span class="type">void</span> QSound::<span class="name">setLoops</span>(<span class="type">int</span> <i>number</i>)</h3>
<p>Sets the sound to repeat the given <i>number</i> of times when it is played.</p>
<p>Note that passing the value <code>QSound::Infinite</code> will cause the sound to loop indefinitely.</p>
<p><b>See also </b><a href="qsound.html#loops">loops</a>().</p>
<!-- @@@setLoops -->
<!-- $$$stop[overload1]$$$stop -->
<h3 class="fn" id="stop"><a name="stop"></a><code>[slot] </code><span class="type">void</span> QSound::<span class="name">stop</span>()</h3>
<p>Stops the sound playing.</p>
<p><b>See also </b><a href="qsound.html#play-1">play</a>().</p>
<!-- @@@stop -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>