Python Cookbook 2Nd Edition Jun 1002005 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Python Cookbook 2Nd Edition Jun 1002005 [Electronic resources] - نسخه متنی

David Ascher, Alex Martelli, Anna Ravenscroft

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Recipe 10.11. Checking Your Windows Sound System


Credit: Anand Pillai


Problem


You need to check whether the
sound subsystem on your Windows PC is properly configured.


Solution


The
winsound module of the Python Standard Library
makes this check really simple:

import winsound
try:
winsound.PlaySound("*", winsound.SND_ALIAS)
except RuntimeError, e:
print 'Sound system has problems,', e
else:
print 'Sound system is OK'


Discussion


The sound system might pass this test and still be unable to produce
sound correctly, due to a variety of possible problemsstarting
from simple ones such as powered loudspeakers being turned off
(there's no sensible way you can check for
that in your program!), all the way to extremely
subtle and complicated ones. When sound is a problem in your
applications, using this recipe at least you know whether you should
be digging into a subtle issue of device driver configuration or
start by checking whether the loudspeakers are on!


See Also


Documentation on the Python Standard Library
winsound module.


/ 394