Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquick3dambientsound.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-3.0-only
5#include "qambientsound.h"
6#include <QAudioFormat>
7#include <qdir.h>
8#include <QQmlContext>
9#include <QQmlFile>
10
12
35
40
47{
48 return m_sound->source();
49}
50
52{
53 const QQmlContext *context = qmlContext(this);
54 QUrl url;
55 if (context) {
56 url = context->resolvedUrl(source);
57 } else {
60 }
61 m_sound->setSource(url);
62}
63
70{
71 m_sound->setVolume(volume);
72}
73
75{
76 return m_sound->volume();
77}
78
88{
89 return m_sound->loops();
90}
91
93{
94 m_sound->setLoops(loops);
95}
96
106{
107 return m_sound->autoPlay();
108}
109
111{
112 m_sound->setAutoPlay(autoPlay);
113}
114
121{
122 m_sound->play();
123}
124
131{
132 m_sound->pause();
133}
134
142{
143 m_sound->stop();
144}
145
\inmodule QtSpatialAudio
void setAutoPlay(bool autoPlay)
void volumeChanged()
void pause()
Pauses sound playback.
void setLoops(int loops)
void play()
Starts playing back the sound.
void loopsChanged()
int loops
Determines how many times the sound is played before the player stops.
float volume
Defines the volume of the sound.
bool autoPlay
Determines whether the sound should automatically start playing when a source gets specified.
void sourceChanged()
void autoPlayChanged()
void setSource(const QUrl &url)
QUrl source
The source file for the sound to be played.
void stop()
Stops sound playback and resets the current position and current loop count to 0.
void setVolume(float volume)
static QString currentPath()
Returns the absolute path of the application's current directory.
Definition qdir.cpp:2054
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
void setAutoPlay(bool autoPlay)
void play()
\qmlmethod AmbientSound::play()
void pause()
\qmlmethod AmbientSound::pause()
void stop()
\qmlmethod AmbientSound::stop()
QQuick3DAmbientSound()
\qmltype AmbientSound \inqmlmodule QtQuick3D.SpatialAudio
void setVolume(float volume)
\qmlproperty float AmbientSound::volume
static QAudioEngine * getEngine()
\inmodule QtCore
Definition qurl.h:94
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition qurl.cpp:3368
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
Definition qurl.cpp:2725
Combined button and popup list for selecting options.
static void * context
GLsizei GLsizei GLchar * source
QQmlContext * qmlContext(const QObject *obj)
Definition qqml.cpp:75
QUrl url("example.com")
[constructor-url-reference]