static void Main(string[] args) { if (Convert.ToInt32(args[0]) == -1) { string soundsRoot = @"I:\ORT_Pendrive\Proyecto\TaskExecute\TaskExecute\bin\Debug\music"; Random rand = new Random(); var soundFiles = Directory.GetFiles(soundsRoot, "*.wav"); var playSound = soundFiles[rand.Next(0, soundFiles.Length)]; System.Media.SoundPlayer player = new System.Media.SoundPlayer(playSound); if (args[1] == "T") { player.Play(); } else { player.Stop(); } Console.Read(); } else { int output = Convert.ToInt32(Math.Pow(2, Convert.ToInt32(args[0]))); int total = PortControl.PortControl.Input(888); if (args[1] == "T") { if (((byte)PortControl.PortControl.Input(888) & (byte)output) == (byte)0) PortControl.PortControl.Output(888, total + output); } else if (((byte)PortControl.PortControl.Input(888) & (byte)output) == output) PortControl.PortControl.Output(888, total - output); Environment.Exit(0); } }
public void game_over(int wynik) { System.Media.SoundPlayer player = new System.Media.SoundPlayer(); player.SoundLocation = "loose.wav"; if (muzik == true) { player.PlayLooping(); } Console.Clear(); for (int i = 0, j= 0 ; i < 25; i++) { if (i >= j) Clear_line_of_numbers(i - j, 7); if (j<6) j++; if (i > 3) { Console.SetCursorPosition(75, i - 4); Console.Write(" ____ ___ "); } if (i > 2) { Console.SetCursorPosition(75, i - 3); Console.Write(" / ___| __ _ _ __ ___ ___ / _ \\__ _____ _ __ "); } if (i > 1) { Console.SetCursorPosition(75, i - 2); Console.Write("| | _ / _` | '_ ` _ \\ / _ \\ | | | \\ \\ / / _ \\ '__|"); } if (i > 0) { Console.SetCursorPosition(75, i - 1); Console.Write("| |_| | (_| | | | | | | __/ | |_| |\\ V / __/ | ");} if (i > -1) {Console.SetCursorPosition(75, i); Console.Write(" \\____|\\__,_|_| |_| |_|\\___| \\___/ \\_/ \\___|_| ");} Thread.Sleep(60); } Console.ForegroundColor = ConsoleColor.DarkGray; int hoffset = 78; int voffset = 30; Console.SetCursorPosition(hoffset, voffset++); Console.WriteLine("╔══════════════════════════════════════════╗"); Console.SetCursorPosition(hoffset, voffset++); Console.WriteLine("╠─────────────Podaj swoje imię─────────────╣"); Console.SetCursorPosition(hoffset, voffset++); Console.WriteLine("╠══════════════════════════════════════════╣"); Console.SetCursorPosition(hoffset, voffset++); Console.WriteLine("║ ║"); Console.SetCursorPosition(hoffset, voffset++); Console.WriteLine("╠══════════════════════════════════════════╣"); Console.SetCursorPosition(hoffset, voffset++); Console.WriteLine("╠───────────────Twój wynik to──────────────╣"); Console.SetCursorPosition(hoffset, voffset++); Console.WriteLine("║ ║"); Console.SetCursorPosition(hoffset, voffset++); Console.WriteLine("╚══════════════════════════════════════════╝"); Console.SetCursorPosition(hoffset + 20, 36); Console.Write(wynik); Console.SetCursorPosition(hoffset+2, 33); Console.ForegroundColor = ConsoleColor.White; Console.CursorVisible=true; string name = Console.ReadLine(); Console.CursorVisible = false; Scoreboard scoreboard = new Scoreboard(); if (name != "") { Player winner = new Player(); winner.name = name; winner.score = wynik; scoreboard.dodaj(winner); } Thread.Sleep(500); player.Stop(); scoreboard.muzik = this.muzik; scoreboard.wypisz(muzik); }
public void SearchandDestroy(bool reset, bool friend, bool foe, bool friendfoe, bool live) { System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.kachu); System.Media.SoundPlayer playerSound = new System.Media.SoundPlayer(Properties.Resources.pkmtheme); TargetManager tm = TargetManager.GetInstance(); Controller controller = Controller.GetInstance(); controller.Launcher = new MissileLauncherAdapter(); Controller cont = Controller.GetInstance(); if(live == false) controller.Launcher.Reset(); int i = 0; if (friend == true) { FriendSD friendClass = new FriendSD(); i = friendClass.SearchandDestroy(reset); } else if (foe == true) { FoeSD foeClass = new FoeSD(); i = foeClass.SearchandDestroy(reset); } else { FriendFoeSD friendFoeClass = new FriendFoeSD(); i = friendFoeClass.SearchandDestroy(reset); } if (controller.GetNum() > 0) { playerSound.Play(); controller.MoveBy(6000, 0); for (int j = 0; j < controller.GetNum();) { controller.Fire(); controller.SetNum(controller.GetNum() - 1); } controller.SetNum(0); playerSound.Stop(); } }
private void Button_Click_Play(object sender, RoutedEventArgs e) { var text = SpeechText.Text; var name = (UseWaveNet.IsChecked ?? false) ? "ja-JP-Wavenet-A" : "ja-JP-Standard-A"; var speed = SpeedSlider.Value; var pitch = PitchSlider.Value; if (_Player != null) { _Player?.Stop(); _Player?.Dispose(); } var input = new SynthesisInput { Text = text }; var voiceSection = new VoiceSelectionParams { Name = name, LanguageCode = "ja-JP", SsmlGender = SsmlVoiceGender.Female, }; var audioConfig = new AudioConfig { AudioEncoding = AudioEncoding.Linear16, SpeakingRate = speed, Pitch = pitch, }; var response = _Client.SynthesizeSpeech(input, voiceSection, audioConfig); using (var memoryStream = new MemoryStream(response.AudioContent.ToArray(), true)) { _Player = new System.Media.SoundPlayer(memoryStream); _Player.Play(); } }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; game.food.Draw(g); System.Media.SoundPlayer pl = new System.Media.SoundPlayer(); if ((game.snake.snake[0].X == game.food.X && game.snake.snake[0].Y == game.food.Y)) { pl.Stream = ZbirIgri.Properties.Resources.bite; pl.Play(); game.snake.addCircle(); game.NovaKrofna(); game.Poeni++; flag = true; } if (prevTime == time) pl.Stop(); Brush b; if (game.dir == SnakeGame.Direction.Right) { g.FillEllipse(Brushes.Black, game.snake.snake[0].X + 20, game.snake.snake[0].Y, 20, 20); prevX = game.snake.snake[0].X; prevY = game.snake.snake[0].Y; game.snake.snake[0].X += 20; } else if (game.dir == SnakeGame.Direction.Down) { g.FillEllipse(Brushes.Black, game.snake.snake[0].X, game.snake.snake[0].Y + 20, 20, 20); prevY = game.snake.snake[0].Y; prevX = game.snake.snake[0].X; game.snake.snake[0].Y += 20; } else if (game.dir == SnakeGame.Direction.Left) { g.FillEllipse(Brushes.Black, game.snake.snake[0].X - 20, game.snake.snake[0].Y, 20, 20); prevY = game.snake.snake[0].Y; prevX = game.snake.snake[0].X; game.snake.snake[0].X -= 20; } else if (game.dir == SnakeGame.Direction.Up) { g.FillEllipse(Brushes.Black, game.snake.snake[0].X, game.snake.snake[0].Y - 20, 20, 20); prevY = game.snake.snake[0].Y; prevX = game.snake.snake[0].X; game.snake.snake[0].Y -= 20; } for (int i = 1; i < game.snake.snake.Count; i++) { b = Brushes.Red; g.FillEllipse(b, prevX, prevY, 20, 20); float tempx = prevX, tempy = prevY; prevX = game.snake.snake[i].X; prevY = game.snake.snake[i].Y; game.snake.snake[i].X = tempx; game.snake.snake[i].Y = tempy; } }
private void Music(bool turn_on) { string soundsRoot = "music"; Random rand = new Random(); var soundFiles = Directory.GetFiles(soundsRoot, "*.wav"); var playSound = soundFiles[rand.Next(0, soundFiles.Length)]; player = new System.Media.SoundPlayer(playSound); if (turn_on) { player.PlayLooping(); } else { player.Stop(); } }
private void thread() { for (; ; ) { DateTime now = DateTime.Now; if ((now.Day == time.Day) && (now.Month == time.Month) && (now.Year == time.Year) && (now.Second == time.Second) && (now.Minute == time.Minute) && (now.Hour == time.Hour)) { textBox.Visible = true; this.WindowState = FormWindowState.Normal; System.Media.SoundPlayer reminderSounbd = null; try { reminderSounbd = new System.Media.SoundPlayer(@"folder_path\alarm.wav"); reminderSounbd.Play(); } catch { MessageBox.Show("Path of sound not exist!"); } MessageBox.Show("Now it's:\n" + textBox.Text, "Alarm!", MessageBoxButtons.OK, MessageBoxIcon.Information); try { reminderSounbd.Stop(); } catch { } break; } Thread.Sleep(500); } tr.Abort(); }
private void stopToolStripMenuItem_Click(object sender, EventArgs e) { player.Stop(); }
/// <summary> /// 把文字转化为声音,单路配置,一种语音 /// </summary> /// <param name="speekText">要转化成语音的文字</param> /// <param name="outWaveFlie">把声音转为文件,默认为不生产wave文件</param> private void speek(string speekText, string outWaveFlie = null) { if (speekText == "" || _speed == "" || _vol == "" || _speeker == "") return; DSpeeker.TryGetValue(speeker, out _speeker); string szParams = "ssm=1," + _speeker + ",spd=" + _speed + ",aue=speex-wb;7,vol=" + _vol + ",auf=audio/L16;rate=16000"; int ret = 0; try { sessionID = Ptr2Str(TTSDll.QTTSSessionBegin(szParams, ref ret)); if (ret != 0) throw new Exception("初始化TTS引会话错误,错误代码:" + ret); ret = TTSDll.QTTSTextPut(sessionID, speekText, (uint)Encoding.Default.GetByteCount(speekText), string.Empty); if (ret != 0) throw new Exception("向服务器发送数据,错误代码:" + ret); IntPtr audio_data; int audio_len = 0; SynthStatus synth_status = SynthStatus.TTS_FLAG_STILL_HAVE_DATA; MemoryStream fs = new MemoryStream(); fs.Write(new byte[44], 0, 44); //写44字节的空文件头 while (synth_status == SynthStatus.TTS_FLAG_STILL_HAVE_DATA) { audio_data = TTSDll.QTTSAudioGet(sessionID, ref audio_len, ref synth_status, ref ret); if (ret != 0) break; byte[] data = new byte[audio_len]; if (audio_len > 0) Marshal.Copy(audio_data, data, 0, audio_len); fs.Write(data, 0, data.Length); } WAVE_Header header = getWave_Header((int)fs.Length - 44); //创建wav文件头 byte[] headerByte = StructToBytes(header); //把文件头结构转化为字节数组 //写入文件头 fs.Position = 0; //定位到文件头 fs.Write(headerByte, 0, headerByte.Length); //写入文件头 fs.Position = 0; System.Media.SoundPlayer pl = new System.Media.SoundPlayer(fs); pl.Stop(); pl.Play(); if (outWaveFlie != null) { FileStream ofs = new FileStream(outWaveFlie, FileMode.Create); fs.WriteTo(ofs); fs.Close(); ofs.Close(); fs = null; ofs = null; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } finally { ret = TTSDll.QTTSSessionEnd(sessionID, ""); if (ret != 0) throw new Exception("结束TTS会话错误,错误代码:" + ret); } }
public static void StopManea() { player?.Stop(); }
private void Start_Animals_Click(object sender, EventArgs e) { var strButton_Text=Start_Animals.Text; System.Media.SoundPlayer player = new System.Media.SoundPlayer(); player.SoundLocation = "C:\\temp\\play.wav"; if (strButton_Text == "Start_Animals") { player.LoadAsync(); player.PlayLooping(); Start_Animals.Text = "Stop"; timer_animals.Enabled = true; //listfile[j].Remove(0); //animals.Image = Image.FromFile("c:\\temp\\dog.png"); //anim //Timer timer = new Timer(); //timer.Interval = 500; //timer.Enabled = true; //timer.Start(); } else { player.Stop(); Start_Animals.Text = "Start_Animals"; timer_animals.Enabled = false; } // //animals.SizeMode = "StretchImage"; }
private void Start_Colors_Click(object sender, EventArgs e) { var strButton_Text = Start_Colors.Text; System.Media.SoundPlayer player = new System.Media.SoundPlayer(); player.SoundLocation = "C:\\temp\\play.wav"; if (strButton_Text == "Start_Colors") { player.LoadAsync(); player.PlayLooping(); Start_Colors.Text = "Stop"; timer_colors.Enabled = true; } else { player.Stop(); Start_Colors.Text = "Start_Colors"; timer_colors.Enabled = false; } }
private void PlayMusic(String audioFile) { _player.Stop(); _player.SoundLocation = audioFile; _player.Play(); }
private void FormAbout_Closing(object sender, EventArgs e) { startMusic.Stop(); }
void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { //obtenemos un diccionario con los elementos semánticos SemanticValue semantics = e.Result.Semantics; string rawText = e.Result.Text; RecognitionResult result = e.Result; if (!semantics.ContainsKey("Lugares")) { if (!semantics.ContainsKey("Poner")) { if (!semantics.ContainsKey("Apagar")) { if (!semantics.ContainsKey("Cambiar")) { if (!semantics.ContainsKey("Encender")) { } else { String musica = ((string)semantics["musica"].Value); synth.Speak("Poniendo " + musica); switch (musica) { case "musica": if (player.SoundLocation == "") { player.SoundLocation = "../../Resources/musica.wav"; } player.Load(); player.Play(); break; /*case "villancico": * player.SoundLocation = "../../Resources/Jingle Bells.wav"; * player.Load(); * player.Play(); * break;*/ } } } else { String sexo = ((string)semantics["Sexo"].Value); synth.Speak("Cambiando " + sexo); switch (sexo) { case "Chico": cuerpo.Image = DressDoll.Properties.Resources.Boy; ChicaOn = false; break; case "Chica": cuerpo.Image = DressDoll.Properties.Resources.Girl_1; ChicaOn = true; break; case "Sexo": if (ChicaOn) { cuerpo.Image = DressDoll.Properties.Resources.Boy; ChicaOn = false; } else { cuerpo.Image = DressDoll.Properties.Resources.Girl_1; ChicaOn = true; } break; } } } else { if (semantics.ContainsKey("musica")) { synth.Speak("Apagando música"); player.Stop(); } } } else { if (semantics.ContainsKey("partesAbajo")) { String ropa = ((string)semantics["partesAbajo"].Value); synth.Speak("Poniendo " + ropa); if (doll.conflictoRopa("ParteAbajo")) { //quitar parte parteEntera.Image parteEntera.Image = null; //poner a false en doll doll.ParteEntera = false; } switch (ropa) { case "Falda": parteAbajo.Image = DressDoll.Properties.Resources.Falda; break; case "Pantalones": parteAbajo.Image = DressDoll.Properties.Resources.Pantalones; break; case "Pantalones cortos": parteAbajo.Image = DressDoll.Properties.Resources.Shorts; break; } //poner a true parte Abajo doll doll.ParteAbajo = true; } else if (semantics.ContainsKey("partesArriba")) { String ropa = ((string)semantics["partesArriba"].Value); synth.Speak("Poniendo " + ropa); if (doll.conflictoRopa("ParteArriba")) { //quitar parte parteEntera.Image parteEntera.Image = null; //poner a false en doll } switch (ropa) { case "Camiseta": parteArriba.Image = DressDoll.Properties.Resources.Camiseta; break; case "Chaqueta": parteArriba.Image = DressDoll.Properties.Resources.Chaqueta; break; case "Abrigo": parteArriba.Image = DressDoll.Properties.Resources.Abrigo; break; case "Blusa": parteArriba.Image = DressDoll.Properties.Resources.Blusa; break; case "Jersey": parteArriba.Image = DressDoll.Properties.Resources.Jersey; break; } //poner a true parte Arriba doll doll.ParteArriba = true; } else if (semantics.ContainsKey("zapatos")) { String ropa = ((string)semantics["zapatos"].Value); synth.Speak("Poniendo " + ropa); switch (ropa) { case "Zapatos": zapatos.Image = DressDoll.Properties.Resources.Zapatos; break; case "Botas": zapatos.Image = DressDoll.Properties.Resources.Botas; break; case "Sandalias": zapatos.Image = DressDoll.Properties.Resources.Sandalias; break; } // poner a true zapatos doll doll.Zapatos = true; } else if (semantics.ContainsKey("parteEntera")) { String ropa = ((string)semantics["parteEntera"].Value); synth.Speak("Poniendo " + ropa); if (doll.conflictoRopa("ParteEntera")) { //quitar parte Arriba y abajo parteEntera.Image parteArriba.Image = null; parteAbajo.Image = null; //poner a false las dos en doll doll.ParteArriba = false; doll.ParteAbajo = false; } switch (ropa) { case "Vestido": parteEntera.Image = DressDoll.Properties.Resources.Vestido; break; case "Playero": parteEntera.Image = DressDoll.Properties.Resources.Playero; break; case "Bikini": parteEntera.Image = DressDoll.Properties.Resources.Bikini; break; case "Bañador": parteEntera.Image = DressDoll.Properties.Resources.Bañador; break; case "Disfraz navideño": parteEntera.Image = DressDoll.Properties.Resources.TrajeFestivo; this.BackgroundImage = DressDoll.Properties.Resources.navidad; //musica player.SoundLocation = "../../Resources/Jingle Bells.wav"; player.Load(); player.Play(); break; case "Disfraz de pirata": parteEntera.Image = DressDoll.Properties.Resources.disfraz; this.BackgroundImage = DressDoll.Properties.Resources.barco; //musica player.SoundLocation = "../../Resources/pirata.wav"; player.Load(); player.Play(); break; } // poner a true parte Entera doll doll.ParteEntera = true; } } if (semantics.ContainsKey("Quitar")) { if (semantics.ContainsKey("partesArriba")) { synth.Speak("Quitando " + semantics["partesArriba"].Value); parteArriba.Image = null; } else if (semantics.ContainsKey("partesAbajo")) { synth.Speak("Quitando " + semantics["partesAbajo"].Value); parteAbajo.Image = null; } else if (semantics.ContainsKey("zapatos")) { synth.Speak("Quitando " + semantics["zapatos"].Value); zapatos.Image = null; } else if (semantics.ContainsKey("parteEntera")) { synth.Speak("Quitando " + semantics["parteEntera"].Value); parteEntera.Image = null; } } } else { String lugar = ((string)semantics["Lugares"].Value); synth.Speak("Yendo a " + lugar); switch (lugar) { case "playa": this.BackgroundImage = DressDoll.Properties.Resources.playa; break; case "parque": this.BackgroundImage = DressDoll.Properties.Resources.parque; break; case "barco": this.BackgroundImage = DressDoll.Properties.Resources.barco; break; case "casa": this.BackgroundImage = DressDoll.Properties.Resources.navidad; break; case "cine": this.BackgroundImage = DressDoll.Properties.Resources.cine; break; case "clase": this.BackgroundImage = DressDoll.Properties.Resources.clase; break; } } }
public void Play() { string trackLocation = ""; System.Media.SoundPlayer sp = new System.Media.SoundPlayer(); sp.SoundLocation = trackLocation; sp.Play(); sp.Stop(); }
static void StartScreen() { System.Media.SoundPlayer startScreenMusic = new System.Media.SoundPlayer(musicBeggining); startScreenMusic.PlayLooping(); Console.SetWindowSize(StartWindowsWidth, StartWindowsHeight); Console.CursorVisible = false; Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine(" ooooooooo ooo ooooooo ooooo ooooo ooo oooo ooo"); Console.WriteLine(" oooooooooo ooooo ooooooooooo oooooo oooooo ooooo ooooo ooo"); Console.WriteLine(" ooo oooo ooooooo ooooo ooooo ooooooo ooooooo ooooooo oooooo ooo"); Console.WriteLine(" oooooooooo ooo ooo oooo ooooooooooooooo ooo ooo ooooooo ooo"); Console.WriteLine(" oooooooo ooooooooooo oooo ooooo oooo ooooo oooo ooooooooooo ooo oooooo"); Console.WriteLine(" ooo ooooooooooo ooooooooooo oooo ooooo oooo ooooooooooo ooo ooooo"); Console.WriteLine(" ooo ooo ooo ooooooo oooo ooo oooo ooo ooo ooo oooo"); Console.WriteLine(); string text = "TEAM MERA'S VESION"; Console.Write("\n{0}", new string('=', (Console.WindowWidth - text.Length) / 2)); Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(text); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write("{0}", new string('=', (Console.WindowWidth - text.Length) / 2)); Console.WriteLine(); Console.WriteLine(); text = "Instructions"; Console.Write("\n{0}", new string('=', (Console.WindowWidth - text.Length) / 2)); Console.ForegroundColor = ConsoleColor.White; Console.Write(text); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.Write("{0}", new string('=', (Console.WindowWidth - text.Length) / 2)); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("To move use arrow keys. Avoid ghosts and collect all the gold as quickly as possible. You got 5 lives. If the ghosts catch you, you lose life. When all lifes are lost your game is over. If you succeed to get all the gold and your timing is good you will enter in Hall of fame :)"); Console.WriteLine("Good luck!"); text = "To start the game press Space"; Console.WriteLine(); Console.Write("{0}{1}{0}", new string(' ', (Console.WindowWidth - text.Length) / 2), text); ConsoleKeyInfo keyInfo = Console.ReadKey(true); while (keyInfo.Key != ConsoleKey.Spacebar) { keyInfo = Console.ReadKey(true); } startScreenMusic.Stop(); Console.Clear(); }
private void Import_HelpButtonClicked(object sender, CancelEventArgs e) { timer1.Enabled = !timer1.Enabled; System.Media.SoundPlayer player = new System.Media.SoundPlayer(@".\BlackFire.wav"); if (timer1.Enabled) player.Play(); else player.Stop(); }
public void stopSound(string soundName) { string path = "..\\..\\Resources\\sounds\\" + soundName + ".wav"; var sound = new System.Media.SoundPlayer(path); sound.Stop(); }
// Start serving up frames private void StartWebcam(Webcam cam, ConnectionManager conManager, StreamWriter sw, ImageCodecInfo myImageCodecInfo, EncoderParameters myEncoderParameters) { MemoryStream m = new MemoryStream(20000); Bitmap image = null; IntPtr ip = IntPtr.Zero; Font fontOverlay = new Font("Times New Roman", 14, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); MotionDetector motionDetector = new MotionDetector(); DateTime lastMotion = DateTime.Now; int interval = 5; stopCondition = false; isRecording = false; player = new System.Media.SoundPlayer(); motionDetector.MotionLevelCalculation = true; player.LoadCompleted += new System.ComponentModel.AsyncCompletedEventHandler((obj, arg) => player.PlayLooping()); cam.Start(); while (!stopCondition) { try { // capture image ip = cam.GetBitMap(); image = new Bitmap(cam.Width, cam.Height, cam.Stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, ip); image.RotateFlip(RotateFlipType.RotateNoneFlipY); motionDetector.ProcessFrame(ref image); if (motionDetector.MotionLevel >= alarmLevel) { if (!isRecording && (DateTime.Now.Second % interval == 0)) conManager.SendMessage("record"); lastMotion = DateTime.Now; } else { if (DateTime.Now.Subtract(lastMotion).Seconds > interval) { if (isRecording) { conManager.SendMessage("stop-record"); isRecording = false; } if (isAlarming) { player.Stop(); isAlarming = false; } } } // add text that displays date time to the image image.AddText(fontOverlay, 10, 10, DateTime.Now.ToString()); // save it to jpeg using quality options image.Save(m, myImageCodecInfo, myEncoderParameters); // send the jpeg image if server requests it if (requested) conManager.SendImage(m); } catch (Exception ex) { try { sw.WriteLine(DateTime.Now.ToString()); sw.WriteLine(ex); } catch { } } finally { // Empty the stream m.SetLength(0); // remove the image from memory if (image != null) { image.Dispose(); image = null; } if (ip != IntPtr.Zero) { Marshal.FreeCoTaskMem(ip); ip = IntPtr.Zero; } } } cam.Pause(); player.Stop(); fontOverlay.Dispose(); }
private void startTask(int posicion, bool turn_on) { if (posicion != -1) { int output = Convert.ToInt32(Math.Pow(2, posicion)); int total = PortControl.PortControl.Input(888); if (turn_on) { if (((byte)PortControl.PortControl.Input(888) & (byte)output) == (byte)0) PortControl.PortControl.Output(888, total + output); } else if (((byte)PortControl.PortControl.Input(888) & (byte)output) == output) PortControl.PortControl.Output(888, total - output); } else { string soundsRoot = "music"; Random rand = new Random(); var soundFiles = Directory.GetFiles(soundsRoot, "*.wav"); var playSound = soundFiles[rand.Next(0, soundFiles.Length)]; player = new System.Media.SoundPlayer(playSound); player.PlayLooping(); if (turn_on) { player.PlayLooping(); } else { player.Stop(); } } }
private void pictureBox3_Click(object sender, EventArgs e) { player.Stop(); }