summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/audio/qsound.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/multimedia/audio/qsound.cpp b/src/multimedia/audio/qsound.cpp
index b6cf49671..7ad30608d 100644
--- a/src/multimedia/audio/qsound.cpp
+++ b/src/multimedia/audio/qsound.cpp
@@ -60,6 +60,9 @@
\snippet multimedia-snippets/qsound.cpp 1
+ In both cases, the file may either be a local file or in a
+ \l{The Qt Resource System}{resource}.
+
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
@@ -88,6 +91,8 @@
/*!
Plays the sound stored in the file specified by the given \a filename.
+ The file can either be a local file or in a \l{The Qt Resource System}{resource}.
+
\sa stop(), loopsRemaining(), isFinished()
*/
void QSound::play(const QString& filename)
@@ -104,13 +109,17 @@ void QSound::play(const QString& filename)
Constructs a QSound object from the file specified by the given \a
filename and with the given \a parent.
+ The file can either be a local file or in a \l{The Qt Resource System}{resource}.
+
\sa play()
*/
QSound::QSound(const QString& filename, QObject* parent)
: QObject(parent)
{
m_soundEffect = new QSoundEffect(this);
- m_soundEffect->setSource(QUrl::fromLocalFile(filename));
+ const bool isQrc = filename.startsWith(QLatin1String("qrc:"), Qt::CaseInsensitive);
+ const QUrl url = isQrc ? QUrl(filename) : QUrl::fromLocalFile(filename);
+ m_soundEffect->setSource(url);
}
/*!