35.4. winsound — Windows 的声音播放界面

版本 1.5.2 中的新Function。

winsound模块提供对 Windows 平台提供的基本声音播放机制的访问。它包括函数和几个常量。

1.6 版中的新Function。

2.3 版的新Function。

所有 Win32 系统至少支持以下内容:大多数系统支持更多:

PlaySound() 名称 对应的控制面板声音名称
'SystemAsterisk' Asterisk
'SystemExclamation' Exclamation
'SystemExit' Exit Windows
'SystemHand' Critical Stop
'SystemQuestion' Question

For example:

import winsound
# Play Windows exit sound.
winsound.PlaySound("SystemExit", winsound.SND_ALIAS)

# Probably play Windows default sound, if any is registered (because
# "*" probably isn't the registered name of any sound).
winsound.PlaySound("*", winsound.SND_ALIAS)

Note

此模块不支持从内存映像异步播放,因此此标志和SND_ASYNC的组合将引发RuntimeError

Note

现代 Windows 平台不支持此标志。

Note

现代 Windows 平台不支持此标志。

首页