• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Media.SoundPlayer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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-08-16_6897529750891327/tv/sharknado/sharknado_afraid.wav";
             break;
         case 2:
             varURL = "http://www.wavsource.com/snds_2015-08-16_6897529750891327/movies/misc/silence_lambs_dinner.wav";
             break;
         case 3:
             varURL = "http://www.wavsource.com/snds_2015-08-16_6897529750891327/movies/aladdin/aladdin_cant_believe.wav";
             break;
         default:
             break;
     }
     quote.SoundLocation = varURL;
     if (quote == null) { }
     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:tcMichaelson,项目名称:Day01,代码行数:28,代码来源:Program.cs


示例17: QuickPlay

 /// <summary>
 /// Plays a stream Asychronously using the System.Media.SoundPlayer Object.
 /// </summary>
 /// <param name="S">Any stream, ex: a wav sound resource.</param>
 public void QuickPlay(System.IO.Stream S)
 {
     SoundPlayer wavPlayer = new SoundPlayer();
     wavPlayer.Stream = S;
     wavPlayer.LoadCompleted += new AsyncCompletedEventHandler(wavPlayer_LoadCompleted);
     wavPlayer.LoadAsync();
 }
开发者ID:RickeyWard,项目名称:Rockband-DrumKit-for-Windows,代码行数:11,代码来源:SoundEngine.cs


示例18: Init

 private void Init()
 {
     soundplayer = new SoundPlayer {
         SoundLocation = filename
     };
     soundplayer.Load();
 }
开发者ID:ralfw,项目名称:CCA_at_the_movies_AppWeckern,代码行数:7,代码来源:Bimmel.cs


示例19: Play

 /// <summary>Plays a .wav sound file.</summary>
 /// <param name="playMode">AudioPlayMode Enumeration mode for playing the sound. By default, AudioPlayMode.Background.</param>
 /// <param name="location">A String containing the name of the sound file </param>
 /// <PermissionSet><IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlThread" /><IPermission class="System.Net.WebPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /></PermissionSet>
 public static void Play(string location, AudioPlayMode playMode)
 {
     ValidateAudioPlayModeEnum(playMode, "playMode");
     string text1 = ValidateFilename(location);
     SoundPlayer player1 = new SoundPlayer(text1);
     Play(player1, playMode);
 }
开发者ID:lamp525,项目名称:DotNet,代码行数:11,代码来源:AudioHelper.cs


示例20: ExerciseView

        // We want to control how depth data gets converted into false-color data
        // for more intuitive visualization, so we keep 32-bit color frame buffer versions of
        // these, to be updated whenever we receive and process a 16-bit frame.
        /*const int RED_IDX = 2;
        const int GREEN_IDX = 1;
        const int BLUE_IDX = 0;
        byte[] depthFrame32 = new byte[320 * 240 * 4];*/
        public ExerciseView(Exercise ex)
        {
            InitializeComponent();

            this.ex = ex;

            statusText.Text = ex.statusMessage;

            passSound = new SoundPlayer("Sounds/ExercisePass.wav");
            passSound.LoadAsync();
            failSound = new SoundPlayer("Sounds/ExerciseFail.wav");
            failSound.LoadAsync();

            #if DEBUG
            lastTime = DateTime.Now;

            fpsLabel = new Label();
            fpsLabel.Content = "FPS:";
            fpsLabel.FontSize = (double)Application.Current.Resources["SmallButtonFont"];
            fpsLabel.HorizontalContentAlignment = HorizontalAlignment.Center;
            fpsLabel.HorizontalAlignment = HorizontalAlignment.Left;
            bottomPanel.Children.Insert(0, fpsLabel);
            #endif

            #if AUDIOUI
            SharedContent.Sr.registerSpeechCommand(SharedContent.Commands.Stop, selectedResponse);
            #endif

            //SharedContent.Nui.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nuiDepthFrameReady);
            SharedContent.Nui.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(nuiSkeletonFrameReady);
            SharedContent.Nui.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nuiColorFrameReady);
        }
开发者ID:drrobson,项目名称:Group42_FYDP,代码行数:39,代码来源:ExerciseView.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Messaging.Message类代码示例发布时间:2022-05-26
下一篇:
C# Runspaces.Runspace类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap