Hi,
I want to add foll logic in my project:
On a certain the condition i want to play the buzzer continuously until stopped by the user.
Please give me some clue
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
FroglegRank #1,020 · 1.9K reputationPosted Oct 16, 2013, 10:55 AM EDT
using System.Media;
namespace SimpleSound
{
public partial class Form1 : Form
{
SoundPlayer mySound = new SoundPlayer("sound.wav");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
mySound.PlayLooping();
}
private void button2_Click(object sender, EventArgs e)
{
mySound.Stop();
}
}
}
VulpesRank #55 · 29.2K reputationPosted Oct 16, 2013, 11:27 AM EDT
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Oct 25, 2013, 11:49 PM EDT
But how can i play that file for particular interval.
For eg: i want to playlooping for 20 minutes and after that completion of interval sound should stop.
Plz give me some suggestion
VulpesRank #55 · 29.2K reputationPosted Oct 26, 2013, 6:08 AM EDT
20 x 60 * 1000 = 1200000 milliseconds.
and its Enabled property to false.
Now start the timer when you start playback:
Finally, handle the timer's Tick event as follows:
private void timer1_Tick(object sender, EventArgs e)
{
mySound.Stop();
timer1.Stop();
}