diff pytouhou/ui/gamerunner.py @ 321:61adb5453e46

Implement music playback.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 13 Jun 2012 15:29:43 +0200
parents f3099ebf4f61
children 2fcdb8966957
line wrap: on
line diff
--- a/pytouhou/ui/gamerunner.py
+++ b/pytouhou/ui/gamerunner.py
@@ -25,6 +25,8 @@ from pyglet.gl import (glMatrixMode, glL
                        GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY,
                        GL_SCISSOR_TEST)
 
+from pyglet.media import Player as MusicPlayer
+
 from pytouhou.utils.helpers import get_logger
 
 from .gamerenderer import GameRenderer
@@ -72,6 +74,13 @@ class GameRunner(pyglet.window.Window, G
         glEnableClientState(GL_VERTEX_ARRAY)
         glEnableClientState(GL_TEXTURE_COORD_ARRAY)
 
+        # Initialize sound
+        self.game.music = MusicPlayer()
+        bgm = self.game.bgms[0]
+        if bgm:
+            self.game.music.queue(bgm)
+        self.game.music.play()
+
         # Use our own loop to ensure 60 (for now, 120) fps
         pyglet.clock.set_fps_limit(120)
         while not self.has_exit: