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


C# Media.SoundPlayer类代码示例

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


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

示例1: AboutBox

        public AboutBox()
        {
            InitializeComponent();
            loc = label1.Location;

            label1.Text = "";
            try
            {
                var rm = new System.Resources.ResourceManager("BizHawk.Client.EmuHawk.Properties.Resources", GetType().Assembly);
                sfx = new SoundPlayer(rm.GetStream("nothawk"));
                sfx.Play();
            }
            catch
            {
            }

            //panel1.Size = new System.Drawing.Size(1000, 1000);
            //pictureBox5.GetType().GetMethod("SetStyle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod).Invoke(pictureBox5, new object[] { ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true });
            pictureBox5.BackColor = Color.Transparent;
            pictureBox5.SendToBack();
            pictureBox3.BringToFront();
            pictureBox2.BringToFront();
            pictureBox1.BringToFront();
            pictureBox5.Visible = false;
        }
开发者ID:cas1993per,项目名称:bizhawk,代码行数:25,代码来源:AboutBox.cs

示例2: BT_jogar_Click_1

 private void BT_jogar_Click_1(object sender, EventArgs e)
 {
     Form7 objform7 = new Form7();
     objform7.Show();
     SoundPlayer IniciarPlayer = new SoundPlayer(Properties.Resources.DingDong);
     IniciarPlayer.Play();
 }
开发者ID:jotacisio,项目名称:who_knows_more,代码行数:7,代码来源:Form2.cs

示例3: ProcessRequest

        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Check we have a sound file.
            var sSound = dArguments.GetValueOrDefault("file", "");
            if (sSound == null || sSound == "")
            {
                Log.Write("Cannot play sound.  Are you missing a 'file' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Attempt to play it.
            try
            {
                SoundPlayer pSound = new SoundPlayer(sSound);
                pSound.Play();
                return true;
            }
            
            // Log warnings.
            catch (Exception e)
            {
                Log.Write("Cannot play sound. " + e.Message, pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }
        }
开发者ID:iNabarawy,项目名称:ubidisplays,代码行数:32,代码来源:PlaySound.cs

示例4: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            ClickSound = new SoundPlayer(spath + label5.Text + "Resources" + label5.Text + "Sound" + label5.Text + "clickSound.wav");
            ClickSound.Play();

            if (comboBox2.SelectedItem != null)
            {
                directoryLabel.Text = sqpath + label5.Text + "Resources" + label5.Text + "logico01.txt";
                TextWriter tw = new StreamWriter(directoryLabel.Text);
                int x = int.Parse(comboBox2.SelectedItem.ToString());
                // проверка дали въведения отговор е верен
                if (x == 11)
                {
                    tw.WriteLine("3");     // записване в текстовия файл

                }
                else
                {
                    if (x == 20)
                        tw.WriteLine("2");
                    else
                        if (x == 9)
                            tw.WriteLine("1");
                        else
                        tw.WriteLine("0");
                }
                MessageBox.Show("Благодаря за вашия отговор.");
                tw.Close();
                Close();
            }
        }
开发者ID:hristo-vrigazov,项目名称:Logico11,代码行数:31,代码来源:Form2.cs

示例5: Play

        public static void Play(SoundType type)
        {
            if (Environment.OSVersion.Platform == PlatformID.Unix) return;
            if (type != SoundType.None) {
                Stream sound;
                switch (type) {
                    case SoundType.Click:
                        sound = Sounds.scificlick;
                        break;
                    case SoundType.Servo:
                        sound = Sounds.panel_move;
                        break;
                    case SoundType.BigClick:
                        sound = Sounds.button_click;
                        break;
                    default:
                        sound = null;
                        break;
                }


                if (sound != null) {
                    var sp = new SoundPlayer(sound);
                    sp.Play();
                }
            }
        }
开发者ID:DeinFreund,项目名称:Zero-K-Infrastructure,代码行数:27,代码来源:SoundPalette.cs

示例6: SE

        public SE()
        {
            p = new SoundPlayer[2];

               p[0] = new SoundPlayer("Content/BGM/SE9.wav");
               p[1] = new SoundPlayer("Content/BGM/SE13.wav");
        }
开发者ID:TowerTin,项目名称:SourceCode,代码行数:7,代码来源:GamePlay.cs

示例7: Game

        public Game(string mapPath)
        {
            totalPoints = 0;

            totalRounds = 9; //TU ILE MAP MA GRA TRZEBA WPISAC

            typewriter = Constants.getSoundPlayerInstance();
            typewriter.Stop();
            typewriter.SoundLocation = "step.wav";

            isNewLevel = true;

            currentPositionInPauseMenu = 0;

            timerPauseMenu = new Timer(500);
            timerPauseMenu.AutoReset = true;
            timerPauseMenu.Elapsed += (s, e) => pasueMenuTick(e);
            timerPauseMenu.Start();

            heroObject = new Hero();
            boxObject = new Box();
            pointObject = new Point();
            floorObject = new Floor();
            wallObject = new Wall();

            mapNumber = 1;
            writelock = new object();
            initMap(mapPath, true);
        }
开发者ID:zaba37,项目名称:Skokoban_KCK,代码行数:29,代码来源:Game.cs

示例8: certo

        public certo()
        {
            InitializeComponent();

            SoundPlayer tocarSom = new SoundPlayer(@"C:\Users\Willian\Desktop\jogo\jogo\imagem\cuco.wav");
            tocarSom.Play();
        }
开发者ID:Bruh,项目名称:Jogo-de-dados,代码行数:7,代码来源:certo.cs

示例9: finalizado

        private void finalizado()
        {
            if (BWAutodestruccion.CancellationPending == false)
            {

                //Se crea una instancia de la clase SoundPlayer
                //que le pasa como parametro al constructo la ruta del archivo
                //con la propiedad FileName del OpenFileDialog
                SoundPlayer player = new SoundPlayer("./explosion-01.wav");
                //Llama el metodo Play del SoundPlayer para reproducir el audio,musica,etc
                player.Play();
                BWAutodestruccion.CancelAsync();
                try
                {
                    Process.Start("notepad.exe", "./ficheroMensaje.txt");
                }
                catch (Exception e)
                {

                }

                Thread.Sleep(6500);
                Application.Exit();
            }
            else
            {
                this.Close();
            }
        }
开发者ID:aitorlomu,项目名称:DisenoDeInterfaces,代码行数:29,代码来源:Autodestruccion.cs

示例10: MainWindow

 internal MainWindow(Archive a)
 {
     InitializeComponent();
       archive = a;
       if(!string.IsNullOrWhiteSpace(archive.settings.sound.backgroundSoundLoc)) {
     main = new SoundPlayer();
     main.SoundLocation = archive.settings.sound.backgroundSoundLoc.RelativeTo(Program.ArchivePath(archive));
     main.PlayLooping();
       }
       if(!string.IsNullOrWhiteSpace(archive.settings.sound.correctSoundLoc)) {
     yes = new SoundPlayer();
     yes.SoundLocation = archive.settings.sound.correctSoundLoc.RelativeTo(Program.ArchivePath(archive));
     yes.LoadAsync();
       }
       if(!string.IsNullOrWhiteSpace(archive.settings.sound.wrongSoundLoc)) {
     no = new SoundPlayer();
     no.SoundLocation = archive.settings.sound.wrongSoundLoc.RelativeTo(Program.ArchivePath(archive));
     no.LoadAsync();
       }
       Text = a.name;
       BackColor = archive.settings.backgroundColor;
       if(!string.IsNullOrWhiteSpace(archive.settings.backgroundLoc)) {
     BackgroundImage = archive.settings.background ?? Extensions.LoadImage(Program.ArchivePath(archive), archive.settings.backgroundLoc);
       }
       Current = new ModeSelect();
 }
开发者ID:svmnotn,项目名称:cuddly-octo-adventure,代码行数:26,代码来源:MainWindow.cs

示例11: PlayAlarm

        public static void PlayAlarm()
        {
            if (player == null)
                player = new SoundPlayer(Assembly.GetExecutingAssembly().GetManifestResourceStream("ReliakTimer.Sounds.ring.wav"));

            player.Play();
        }
开发者ID:reliak,项目名称:reliak-timer,代码行数:7,代码来源:SoundHelper.cs

示例12: BT_jogar_Click_1

 private void BT_jogar_Click_1(object sender, EventArgs e)
 {
     Form7 objform7 = new Form7();
     objform7.Show();
     SoundPlayer IniciarPlayer = new SoundPlayer(@"G:\Arquivos de música.wav\DingDong.wav");
     IniciarPlayer.Play();
 }
开发者ID:jotacisio,项目名称:who_knows_more,代码行数:7,代码来源:Form2.cs

示例13: BeepBeep

        public static void BeepBeep(int Amplitude, int Frequency, int Duration)
        {
            double A = ((Amplitude * (System.Math.Pow(2, 15))) / 1000) - 1;
            double DeltaFT = 2 * Math.PI * Frequency / 44100.0;

            int Samples = 441 * Duration / 10;
            int Bytes = Samples * 4;
            int[] Hdr = { 0X46464952, 36 + Bytes, 0X45564157, 0X20746D66, 16, 0X20001, 44100, 176400, 0X100004, 0X61746164, Bytes };
            using (MemoryStream MS = new MemoryStream(44 + Bytes))
            {
                using (BinaryWriter BW = new BinaryWriter(MS))
                {
                    for (int I = 0; I < Hdr.Length; I++)
                    {
                        BW.Write(Hdr[I]);
                    }
                    for (int T = 0; T < Samples; T++)
                    {
                        short Sample = System.Convert.ToInt16(A * Math.Sin(DeltaFT * T));
                        BW.Write(Sample);
                        BW.Write(Sample);
                    }
                    BW.Flush();
                    MS.Seek(0, SeekOrigin.Begin);
                    using (SoundPlayer SP = new SoundPlayer(MS))
                    {
                        SP.PlaySync();
                    }
                }
            }
        }
开发者ID:vternal3,项目名称:ASCII-RPG,代码行数:31,代码来源:Beep.cs

示例14: FinalWindow

        public FinalWindow()
        {
            InitializeComponent();
            this.ShowInTaskbar = true;

            Thread oThread = new Thread(new ThreadStart(this.listen));
            oThread.Start();

            while (oThread.IsAlive)
            {
                Thread.Sleep(50);
                Application.DoEvents();
            }

            SoundPlayer simpleSound = new SoundPlayer(@"data\sounds\ding.wav");
            simpleSound.Play();

            string[] fileArray = Directory.GetFiles(@"data\graphs", "*.svg");
            foreach (String f in fileArray)
            {
                string filenameWithoutPath = Path.GetFileName(f);
                comboBox1.Items.Add(filenameWithoutPath);
            }
            comboBox1.SelectedIndex = 0;
        }
开发者ID:SebastianLasisz,项目名称:Processing-video,代码行数:25,代码来源:FinalWindow.cs

示例15: Main

        static void Main(string[] args)
        {
            string varURL = "";
            SoundPlayer quote = new SoundPlayer();
            Random randNum = new Random();
            int selectedQuote = (randNum.Next(1, 3));
            switch (selectedQuote)
            {
                case 1:
                    varURL = "http://www.wavsource.com/snds_2015-09-20_4380281261564803/tv/simpsons/apu/bastard.wav";
                    break;
                case 2:
                    varURL = "http://www.wavsource.com/snds_2015-09-20_4380281261564803/tv/simpsons/apu/do_not_listen.wav";
                    break;
                case 3:
                    varURL = "http://www.wavsource.com/snds_2015-09-20_4380281261564803/tv/simpsons/apu/hell.wav";
                    break;
                default:
                    break;
            }
            quote.SoundLocation = varURL;

            try
            {
                quote.Play();
            }
            catch (Exception e)
            {
                Console.WriteLine(@"i'm sorry, you are not connected to the internet. please reconnect and try again.");
            }

            Console.ReadLine();
        }
开发者ID:layzboy17,项目名称:moviequotes,代码行数:33,代码来源:Program.cs


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