Install a hook from audio to animations if both are present.
[pwl6.git] / src / yuu / director.js
index a078ef5..7660b26 100644 (file)
         var director = yuu.director = new yuu.Director();
             /** The standard director */
 
+        if (yuu.audio) {
+            yuu.Animation.registerOperation(function playSound (sound) {
+                if (Array.isArray(sound))
+                    sound = yuu.random.choice(sound);
+                (new yuu.Instrument(sound)).play();
+            });
+        }
+
         yuu.registerInitHook(function () {
             return yuu.ready(director._scenes);
         });