Sound doesn't play

HARRY

Active Member
Licensed User
Longtime User
Hi,

I have written a small program to repeatedly give an audible alarm when there are unread (SMS) messages.

The program runs in principle in the background using ShowTodayScreen and reads from the Registry on intervals based on a timer (Check timer) the unread message count.

When this count is > than 0, the form is shown indicating the number of unread messages and another timer (Sound timer) is started to play repeatedly a small wave file with increasing intervals.

More in detail, when the Check timer fires, the program:

-Puts backlight on
-Shows the screen
-On the added formactivated event it checks the orientation and reorganizes the form when the orientation has changed (only two controls)
-The Check timer is disabled
-The Sound timer is enabled

When the Sound timer fires:
-The form is shown
-Formactivated is executed
-The required interval for playing is checked
-The sound is played

With pressing a button the user can indicate that he has read the count information. Then the Sound timer is disabled, the Check timer is enabled, backlight is set to normal and ShowTodayScreen is activated again.

The program runs fine until the user puts off the backlight manually.

Then the tick event routine of the Sound timer is executed as usual , however the sound is not played.

Sometimes, the sound is played one or more times when the program is sent to background as if the play commands are on stock!

Does somebody have an explanation of this behaviour and a remedy?

Harry
 

HARRY

Active Member
Licensed User
Longtime User
Hi,

Further information on this problem.

The problem also occurs with the WavePlayer.dll and with the Hekkus Library.

Somewhere on internet I found that entering the stand by mode should break the connection with the speaker(???).

Therefore I thought it could be usefull to dispose and set up the objects used in Hekkus each time the wave file should be played. However this gives another problem.

The following small program illustrates the problem:

Form1.Show
Exception1.New1
Speaker1.New1
Speaker1.Dispose
Speaker1.New1
Exception1.ControlRef = B4PObject(6)
Msgbox(Exception1.Name)

The error occurs on the underscored line. the message is (translated to English) "The object reference does not refer to an object".

I used this type of code earlier for other objects without problem.

Does somebody understand this?

Harry
 

HARRY

Active Member
Licensed User
Longtime User
Thanks Andrew.

Shame on me, I coded it again from my memory in stead of looking exactly how I did it before.

By the way, on my device (HTC) entering stand by mode stops the timer of a back ground program after 4-5 seconds. That makes testing confusing: if you test quickly then it works; when you are a little bit slower then it doesn't work.

If just the light is turned off, then such a program which does a minimum of coding on one interrupt per minute still consumes 3 % of the cpu, which is rather power consuming.

Harry
 
Top