当前位置: 首页>>代码示例>>C#>>正文


C# System.Media.SoundPlayer.Stop方法代码示例

本文整理汇总了C#中System.Media.SoundPlayer.Stop方法的典型用法代码示例。如果您正苦于以下问题:C# System.Media.SoundPlayer.Stop方法的具体用法?C# System.Media.SoundPlayer.Stop怎么用?C# System.Media.SoundPlayer.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Media.SoundPlayer的用法示例。


在下文中一共展示了System.Media.SoundPlayer.Stop方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

 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);
     }
 }
开发者ID:adsnaider,项目名称:Automated-House,代码行数:34,代码来源:Program.cs

示例2: game_over

 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);
 }
开发者ID:gornikp,项目名称:projektKCK,代码行数:50,代码来源:GameViewer.cs

示例3: SearchandDestroy

        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();
            }
        }
开发者ID:jon-churchill,项目名称:ASML,代码行数:49,代码来源:SD.cs

示例4: startTask

 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();
         }
     }
 }
开发者ID:adsnaider,项目名称:Automated-House,代码行数:32,代码来源:Cuarto.cs

示例5: stopSound

 public void stopSound(string soundName)
 {
     string path = "..\\..\\Resources\\sounds\\" + soundName + ".wav";
     var sound = new System.Media.SoundPlayer(path);
     sound.Stop();
 }
开发者ID:RisteJovanoski,项目名称:Ladders,代码行数:6,代码来源:Game.cs

示例6: speek

        /// <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);
            }
        }
开发者ID:playboy210,项目名称:playboy,代码行数:63,代码来源:iFlyDotNet.cs

示例7: Play

 public void Play()
 {
     string trackLocation = "";
     System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
     sp.SoundLocation = trackLocation;
     sp.Play();
     sp.Stop();
 }
开发者ID:rajankz,项目名称:ThreadDrum,代码行数:8,代码来源:Form1.cs

示例8: pictureBox1_Paint

        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;

            }
        }
开发者ID:nadicanikolova,项目名称:Nov,代码行数:59,代码来源:ZmijaForm.cs

示例9: Music

 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();
     }
 }
开发者ID:adsnaider,项目名称:Automated-House,代码行数:16,代码来源:Usuarios.cs

示例10: thread

        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();
        }
开发者ID:kira333,项目名称:MyProjects,代码行数:41,代码来源:MainForm.cs

示例11: StartWebcam

        // 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();
        }
开发者ID:eaglezhao,项目名称:tracnghiemweb,代码行数:99,代码来源:MainWindow.xaml.cs

示例12: Import_HelpButtonClicked

        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();
        }
开发者ID:swoonzj,项目名称:Inventory,代码行数:8,代码来源:Import.cs

示例13: Start_Animals_Click

        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";
        }
开发者ID:xneo123,项目名称:PictureLottery,代码行数:30,代码来源:Form1.cs

示例14: Start_Colors_Click

        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;
            }
        }
开发者ID:xneo123,项目名称:PictureLottery,代码行数:21,代码来源:Form1.cs


注:本文中的System.Media.SoundPlayer.Stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。