PlaySound while not in Focus

Posted by Rynok on Sun 25 Jan 2009 04:22 AM — 2 posts, 13,548 views.

USA #0
It looks like PlaySound() doesn't kick off if MUSHclient isn't currently in Focus (as in, if I have mushclient running in the background while I surf the net, I won't hear sounds from the PlaySound() function)

Is there a way around this, or is this intended?
I saw that it had options for looping and volume and speaker direction, but I didn't see anything about it not playing at all when not in focus.

The workaround I found seems to be that you have it fire off a trigger that has the Sound play inside of it when it fires (not through PlaySound() but through MUSHclient itself).
Australia Forum Administrator #1
This forum thread is referred to in the PlaySound documentation:

http://mushclient.com/forum/?id=8721

In there I note:

Quote:

Apparently sounds can stop playing if you Alt+Tab to another application (or simply switch windows), and then switch back. Your scripts might want to periodically check whether music or ambient sounds they have started earlier are still playing (use GetSoundStatus), and if not, start them again.

Under the current configuration, the sounds stop playing if you make another application active, and then resume when MUSHclient is the foreground application again (or at least, it does for me).


Thus the behaviour you are getting is expected.

The PlaySound and related functions were really intended for playing multiple sounds during a battle (which sounds quite neat) like sword hits, grunts, spellups, and so on, merged with background music and ambient sounds. Hence the emphasis on multiple buffers, panning, volume levels and so on.

For the simple case of a sound notification, on a trigger, when the application is not active, the Sound function is probably the best.

Note that GetInfo (113) tells you if the world is currently active or not.