how can i stop looping sound in c# (visual studio)

if (ConditionTrue)
                SoundPlayer simpleSound = new SoundPlayer(@"C:\Users\BIB HUTI\Desktop\beep.wav");

       // it keeps playing and never stops.

Your code will not loop the sound! is this code placed inside a loop? if yes add break; to it.

Use a stop button or something of the like and use the Stop() method.

sorry but i need to play a sound at a specific time ( 12:00 AM). It played but didn't stop playing. Moreover, it's like an alarm and i dont want to use a button for that.

Ok since you are using time to start your sound, add the stop code and initiate it at let's say 12:01AM fair enough?

Thanks buddy . I never thought that way

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.