sound.Player in scene
-
Is it possible to get a sound.Player to play in a scene? I have tried the following code in the setup method:
music_player = sound.Player(file_path) music_player.play()
But it does not work.
sound.play_effect(file_path)
does work though, and both of these work when not presented in a scene. Is there a way to make it work?
-
The problem is probably that
music_player
is a local variable, and falls out of scope (gets garbage-collected) when thesetup
method returns. Tryself.music_player = ...
instead to make it an attribute of the scene.
-
Ah yes, forgot about that. Works fine now.