Modified:
trunk/trunk/runtime/script_objects.py
Log:
on the way to reducing requirement of ao and ogg to a soft dependency
Modified: trunk/trunk/runtime/script_objects.py
==============================================================================
--- trunk/trunk/runtime/script_objects.py (original)
+++ trunk/trunk/runtime/script_objects.py Tue Feb 17 07:16:30 2009
@@ -6,11 +6,16 @@
import pickle
from gb_exceptions import *
-
-import ao
import sys
-import ogg.vorbis
import threading
+
+sound_available=None
+try:
+ import ao
+ import ogg.vorbis
+ sound_available = "ao"
+except:
+ pass
"""
******************************************
script objects:
@@ -474,6 +479,9 @@
class script_sounds(threading.Thread):
def __init__(self, songtitle, loop, device_type="oss"):
+ if sound_available is None:
+ return
+
threading.Thread.__init__(self)
try:
self.mf = ogg.vorbis.VorbisFile(songtitle)
@@ -492,6 +500,9 @@
self.started = False
def run(self):
+ if sound_available is None:
+ return
+
while self.play:
if self.paused == False:
(buf, bytes, bit) = self.mf.read(4096)
@@ -503,11 +514,17 @@
self.dev.play(buf, bytes)
def stop_sound(self):
+ if sound_available is None:
+ return
+
if self.play:
self.mf.time_seek(0)
self.paused = True
def play_sound(self):
+ if sound_available is None:
+ return
+
if self.play:
if self.started is False:
self.start()