| To: | REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com> |
|---|---|
| Subject: | Re: Sound.Stop in Win32 Not Working? |
| From: | Richard <rfs at yadtel dot net> |
| Date: | Wed, 30 Jul 2003 12:32:08 -0400 |
|
OK, for Win32 builds I wrote a small program that plays any of 3
mp3 sounds that have been loaded from disk when the app starts up. I
strike a key (1, 2 or 3) to play or replay any of the sounds, and have
an indicator in my window that tells me if "IsPlaying"
is true or false, for all of the 3 sounds - in addition to my own
ears. If I play any of the sounds it stops the sound that was playing
(if any) and plays the sound I specified. There is no ".Stop"
directive issued in this test program. The strange thing is, that if I
start a Sound2 playing while Sound1 is already playing, then
"IsPlaying" continues to return true for Sound1 -- until I
play Sound1 again, at which time it indicates not-playing when it
ends.
One difference I see here is that for sounds loaded from disk, I
can only play 1 sound at a time. If any other sound is playing, it
stops when I initiate a 2nd sound, regardless whether the 2nd sound is
the same sound or not. Whereas, sounds dragged into the project will
allow me to play multiple different sounds simultaneously, but I
cannot stop a sound already playing so that I can restart that same
sound.
This is my test: A window, an editfield, 3 checkboxes
"CB1" ... "CB3", a timer, and 3 window properties
S1 ..S3 as Sound. 6 sound files on disk, Sound1.snd thru Sound3.snd
(Sys7 sounds) and Sound1.mp3 thru Sound3.mp3. Pressing any key
1..3 starts that sound playing.
In Window:Open
Dim f as FolderItem
#If TargetMacOS then f = GetFolderItem("Sound1.snd") S1 = f.OpenAsSound f = GetFolderItem("Sound2.snd") S2 = f.OpenAsSound f = GetFolderItem("Sound3.snd") S3 = f.OpenAsSound #else f = GetFolderItem("Sound1.mp3") S1 = f.OpenAsSound f = GetFolderItem("Sound2.mp3") S2 = f.OpenAsSound f = GetFolderItem("Sound3.mp3") S3 = f.OpenAsSound #endif Timer1.Period = 100 In Timer:Action
If S1.IsPlaying then CB1.Value = true else CB1.Value =
false
If S2.IsPlaying then CB2.Value = true else CB2.Value = false If S3.IsPlaying then CB3.Value = true else CB3.Value = false In EditField:TextChange
If len(Me.Text)>0 then
Select Case Left(Me.Text,1) Case "1" S1.Play Case "2" S2.Play Case "3" S3.Play End Select Me.Text = "" end if Sorry I didn't mention that... this was a sound dragged into the project. I'll be testing loaded sounds next and I'll report that when I finish, if you don't beat me to it. :) |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Constructors for Modules, Keith DeLong |
|---|---|
| Next by Date: | Re: Constructors for Modules, Joseph J. Strout |
| Previous by Thread: | Re: Sound.Stop in Win32 Not Working?, Richard |
| Next by Thread: | Windows Memory Leak, Ola Olsson |
| Indexes: | [Date] [Thread] [Top] [All Lists] |