Merged revisions 81642 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r81642 | brian.curtin | 2010-06-01 08:49:19 -0500 (Tue, 01 Jun 2010) | 10 lines Merged revisions 81640 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r81640 | brian.curtin | 2010-06-01 08:29:13 -0500 (Tue, 01 Jun 2010) | 3 lines Fix #8618. Ask the Windows mixer API if there are any playback devices configured before attempting to test PlaySound. ........ ................
This commit is contained in:
parent
efafdc7d10
commit
f879c7911f
|
@ -6,6 +6,7 @@ support.requires('audio')
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import ctypes
|
||||||
|
|
||||||
winsound = support.import_module('winsound')
|
winsound = support.import_module('winsound')
|
||||||
import winreg
|
import winreg
|
||||||
|
@ -13,6 +14,11 @@ import winreg
|
||||||
def has_sound(sound):
|
def has_sound(sound):
|
||||||
"""Find out if a particular event is configured with a default sound"""
|
"""Find out if a particular event is configured with a default sound"""
|
||||||
try:
|
try:
|
||||||
|
# Ask the mixer API for the number of devices it knows about.
|
||||||
|
# When there are no devices, PlaySound will fail.
|
||||||
|
if ctypes.windll.winmm.mixerGetNumDevs() is 0:
|
||||||
|
return False
|
||||||
|
|
||||||
key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER,
|
key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER,
|
||||||
"AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
|
"AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
|
||||||
value = winreg.EnumValue(key, 0)[1]
|
value = winreg.EnumValue(key, 0)[1]
|
||||||
|
|
Loading…
Reference in New Issue