Newbie Question on PlaySound

Brett g Porter BgPorter at NOartlogicSPAM.com
Tue Sep 19 12:00:19 EDT 2000


<OneDay at A.Time> wrote in message news:8q810g$hg9$1 at earth.superlink.net...
> Hello,
>
> Thanks for the response on the screen saver issue. (You don'y know unless
you
> ask)
>
> Anyhow, Could someone tell me why the following plays the windows default
> sound file rather than the sound file indicated?
>
> >>>> from winsound import *
> >>>> import os
> >>>> file = open("C:\\windows\\media\\office97\\reminder.wav", 'r')
> >>>> x = file.read()
> >>>> PlaySound(x, SND_FILENAME)
Assuming that PlaySound here is just a wrapper for the Win32 API PlaySound,
you're telling the system that you're sending it a filename (thus the
SND_FILENAME parameter), but you're attempting to pass it the contents of
the file instead.

The API docs for PlaySound say:
'''If it cannot find the specified sound, PlaySound uses the default system
event sound entry instead. If the function can find neither the system
default entry nor the default sound, it makes no sound and returns FALSE.'''

Try replacing your code with

PlaySound("C:\\windows\\media\\office97\\reminder.wav", SND_FILENAME)


--
// Brett g Porter * Senior Engineer, Application Development
// BgPorter @ artlogic . com * http://www.artlogic.com
// Art & Logic * Custom software solutions for hardware products
// Windows * MacOS * Embedded Systems






More information about the Python-list mailing list