mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 17:56:43 +02:00
fixed looping sample sound bug
This commit is contained in:
parent
895f79fd80
commit
cd97ab0fdf
1 changed files with 14 additions and 4 deletions
|
@ -29,12 +29,22 @@ RowLayout {
|
||||||
function playSound() {
|
function playSound() {
|
||||||
// FIXME: MyAvatar is not properly exposed to QML; MyAvatar.qmlPosition is a stopgap
|
// FIXME: MyAvatar is not properly exposed to QML; MyAvatar.qmlPosition is a stopgap
|
||||||
// FIXME: Audio.playSystemSound should not require position
|
// FIXME: Audio.playSystemSound should not require position
|
||||||
sample = Audio.playSystemSound(sound, MyAvatar.qmlPosition);
|
if (sample === null && !isPlaying) {
|
||||||
isPlaying = true;
|
sample = Audio.playSystemSound(sound, MyAvatar.qmlPosition);
|
||||||
sample.finished.connect(function() { isPlaying = false; sample = null; });
|
isPlaying = true;
|
||||||
|
sample.finished.connect(reset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function stopSound() {
|
function stopSound() {
|
||||||
sample && sample.stop();
|
if (sample && isPlaying) {
|
||||||
|
sample.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
sample.finished.disconnect(reset);
|
||||||
|
isPlaying = false;
|
||||||
|
sample = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: createSampleSound();
|
Component.onCompleted: createSampleSound();
|
||||||
|
|
Loading…
Reference in a new issue