473,237 Members | 1,256 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

Playsound loop not working

I need to play a .wav file over and over again. I am using the
following code.

[DllImport("winmm.dll")]
private static extern bool PlaySound( string lpszName, int hModule, int
dwFlags );

public int SND_ASYNC = 0x0001; // play asynchronously
public int SND_LOOP = 0x0008; // loop the sound until next
PlaySound

PlaySound( wavfile, 0, (SND_ASYNC | SND_LOOP));

But it plays only once and stop. Any idea what's wrong ?

Thanks in advance.

Nov 24 '06 #1
3 3134
Hello, tamarindm!

Just a hint in .NET 2.0 there is SoundPlayer class,
that can be used to play sounds and internally uses
PlaySound func


tI need to play a .wav file over and over again. I am using the
tfollowing code.

t[DllImport("winmm.dll")]
tprivate static extern bool PlaySound( string lpszName, int hModule,
tint
tdwFlags );

tpublic int SND_ASYNC = 0x0001; // play asynchronously
tpublic int SND_LOOP = 0x0008; // loop the sound until next
tPlaySound

tPlaySound( wavfile, 0, (SND_ASYNC | SND_LOOP));

tBut it plays only once and stop. Any idea what's wrong ?

tThanks in advance.


--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Nov 24 '06 #2
Thanks but I am using .NET 1.1.

Still need help !
Vadym Stetsyak wrote:
Hello, tamarindm!

Just a hint in .NET 2.0 there is SoundPlayer class,
that can be used to play sounds and internally uses
PlaySound func
tI need to play a .wav file over and over again. I am using the
tfollowing code.

t[DllImport("winmm.dll")]
tprivate static extern bool PlaySound( string lpszName, int hModule,
tint
tdwFlags );

tpublic int SND_ASYNC = 0x0001; // play asynchronously
tpublic int SND_LOOP = 0x0008; // loop the sound until next
tPlaySound

tPlaySound( wavfile, 0, (SND_ASYNC | SND_LOOP));

tBut it plays only once and stop. Any idea what's wrong ?

tThanks in advance.
--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Nov 24 '06 #3
Ummm... Thinking of hack between .Net 1.1 and .Net 2.0....

I am thinking of loading .net 2.0 assembly in .net 1.1

system.dll would be good enough.... not much sure about it....let me
try it....

Thanks
-Srinivas.
tamarindm wrote:
I need to play a .wav file over and over again. I am using the
following code.

[DllImport("winmm.dll")]
private static extern bool PlaySound( string lpszName, int hModule, int
dwFlags );

public int SND_ASYNC = 0x0001; // play asynchronously
public int SND_LOOP = 0x0008; // loop the sound until next
PlaySound

PlaySound( wavfile, 0, (SND_ASYNC | SND_LOOP));

But it plays only once and stop. Any idea what's wrong ?

Thanks in advance.
Nov 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: bballmitch | last post by:
Why won't the following code work? char soundfile2 = "C:/Windows/Media/pinky and the brain.wav"; PlaySound(soundfile2,NULL,SND_FILENAME|SND_SYNC|SND_ASYNC); getchar(); i put libwinmm.a in...
5
by: MLH | last post by:
I have a line of code that works when called from a procedure in Access 2.0 form... PlaySound("C:\cr\help\Help0018.wav", 0) I imported what I thought was needed into A97. However, running it...
3
by: Harry J. Smith | last post by:
I added some sounds to my application, but the example in the msdn Library did not work. It had: public static extern bool PlaySound( string szSound, IntPtr hMod, PlaySoundFlags flags ); The...
4
by: rcattral | last post by:
Has anybody been using the PlaySound() function to play WAV files from within a DLL? Here is what I normally do. Since upgrading to 7.1 NET after using VC 6.0 for quite some time, I found that I...
2
by: Joe Thompson | last post by:
Hi, I am trying to use PlaySound in a VC++.net Windows app (VS 2003). I can use it to play a file but now I want to play it from a resource. I have two questions: How do I add a wav file to...
10
by: Ot | last post by:
I found information on PlaySound. I implemented it in my program and it works just dandy. The only little problem is that I have to package the ..wav files and send them along since PlaySound...
9
by: Andy | last post by:
Hi, I have an application that has several forms. Each form acts as a monitor of a gateway system. If the gateway appears to be dead, the application should play a .wav file (not resource)...
3
by: Jared | last post by:
I'm using the first code sample below to play WAV files stored as embedded resources. For some reason I *occasionally* get scratching and crackling. I'm using a couple WAVs that ship with...
0
by: poppy | last post by:
I tried to play a wav file with function Playsound() but it played only the first seconds of the song.I would like to play whole the song.What might de be wrong?Here is my code in case someone can...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.