summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-05-04 08:29:36 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-05-04 08:29:36 -0400
commit2e0780740a6e9515e76599cecb5a0cff7de196e6 (patch)
treec9b588b8029ac795f5f95ecd38d5008ba5cf770a
parent6233cb8aaebe552b82a1911482929db9e0716650 (diff)
scene: Don't play music when scene isn't active.
-rw-r--r--starling/scene.scm14
1 files changed, 7 insertions, 7 deletions
diff --git a/starling/scene.scm b/starling/scene.scm
index 16630ba..8757ad8 100644
--- a/starling/scene.scm
+++ b/starling/scene.scm
@@ -65,13 +65,13 @@
(define-method (refresh-background-music (scene <scene>))
(let ((source (background-music-source scene)))
- (if (audio? (background-music scene))
- (begin
- (set-source-volume! source (background-music-volume scene))
- (set-source-loop! source (background-music-loop? scene))
- (set-source-audio! source (background-music scene))
- (source-play source))
- (source-stop (background-music-source scene)))))
+ (set-source-volume! source (background-music-volume scene))
+ (set-source-loop! source (background-music-loop? scene))
+ (when (audio? (background-music scene))
+ (set-source-audio! source (background-music scene))
+ (if (active? scene)
+ (source-play source)
+ (source-stop source)))))
(define-method (on-change (scene <scene>) slot-name old new)
(case slot-name