Commits

Stefan Scherfke  committed 5d17299

Fixed issue #15. Python is now used to play the sound.

  • Participants
  • Parent commits 7a6282c

Comments (0)

Files changed (2)

File Tea Timer.wdgt/Scripts/Timer.js

          message += ' ' + getLocalizedString('is ready.');
 
     if ((!type || type == 'sound') && alarm.sound != 'none') {
-        $('#soundPlayer').remove();
-        $('#alarm').append('<embed name="soundPlayer" id="soundPlayer" '
-                + 'src="/System/Library/Sounds/' + alarm.sound + '.aiff" '
-                + 'autostart="false" hidden="true" enablejavascript="true" />');
-        $('#soundPlayer').get(0).Play();
+        widget.system('/usr/bin/python util.py play_sound ' + alarm.sound,
+                function(){});
     }
     if (window.widget && (!type || type == 'growl') && alarm.growl) {
         var sticky = false;
             sticky = true;
 
         if (!isRepeating) {
-            widget.system('/usr/bin/env python growl.py "' + title + '" "'
+            widget.system('/usr/bin/python growl.py "' + title + '" "'
                 + message + '" ' + sticky, function(){});
         }
     }

File Tea Timer.wdgt/util.py

     print ','.join(items)
 
 
+def play_sound(sound):
+    sound_file = '%s/%s.aiff' % (dirs['sounds'], sound)
+
+    import time
+    from AppKit import NSSound
+    player = NSSound.alloc()
+    player.initWithContentsOfFile_byReference_(sound_file, True)
+    player.play()
+    time.sleep(player.duration() + 0.5)
+
+
 if __name__ == '__main__':
-    get_list(sys.argv[1])
+    if sys.argv[1] == 'play_sound':
+        play_sound(sys.argv[2])
+    else:
+        get_list(sys.argv[1])