當前位置: 首頁>>代碼示例>>C#>>正文


C# XAudio2.StopEngine方法代碼示例

本文整理匯總了C#中SharpDX.XAudio2.XAudio2.StopEngine方法的典型用法代碼示例。如果您正苦於以下問題:C# XAudio2.StopEngine方法的具體用法?C# XAudio2.StopEngine怎麽用?C# XAudio2.StopEngine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SharpDX.XAudio2.XAudio2的用法示例。


在下文中一共展示了XAudio2.StopEngine方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        public static void Main(string[] args)
        {
            xaudio2 = new XAudio2();
            xaudio2.StartEngine();
            var masteringVoice = new MasteringVoice(xaudio2);

            if (!string.IsNullOrEmpty(Properties.Settings.Default.BackgroundMusicPath) &&
                Directory.Exists(Properties.Settings.Default.BackgroundMusicPath))
            {
                var musicFiles = Directory.GetFiles(Properties.Settings.Default.BackgroundMusicPath, "*.wav");
                if(musicFiles.Length > 0)
                    backgroundPlayer = new TrackPlayer(xaudio2, musicFiles);
            }

            var listener = new UdpClient(10009);
            listener.BeginReceive(new AsyncCallback(ReceiveCallback), listener);

            effectManager = new EffectManager(xaudio2, 4, Properties.Settings.Default.FXPath);

            // Wait until its done
            int count = 1;
            while (true)
            {
                Thread.Sleep(10);

                if (Console.KeyAvailable)
                {
                    var key = Console.ReadKey();
                    if (key.Key == ConsoleKey.Escape)
                        break;

                    switch (key.Key)
                    {
                        case ConsoleKey.A:
                            effectManager.Play("Scream.wav");
                            break;
                        case ConsoleKey.B:
                            effectManager.Play("Violin screech.wav");
                            break;
                        case ConsoleKey.N:
                            if(backgroundPlayer != null)
                                backgroundPlayer.NextTrack();
                            break;
                        case ConsoleKey.V:
                            if (key.Modifiers.HasFlag(ConsoleModifiers.Shift))
                                backgroundVolume -= 0.1f;
                            else
                                backgroundVolume += 0.1f;

                            if (backgroundVolume < 0f)
                                backgroundVolume = 0f;
                            if (backgroundVolume > 1f)
                                backgroundVolume = 1f;
                            break;
                    }
                }

                var muteMusic = effectManager.AreAnyPlaying && autoMuteBackground ? 0.2f : 0f;
                if (backgroundPlayer != null)
                    backgroundPlayer.Volume = backgroundVolume - muteMusic;

                if (count % 50 == 0)
                {
                    Console.Write(".");
                    Console.Out.Flush();
                }

                Thread.Sleep(10);
                count++;
            }

            listener.Close();

            if (backgroundPlayer != null)
                backgroundPlayer.Stop();
            if (trackPlayer != null)
                trackPlayer.Stop();

            effectManager.Dispose();

            Thread.Sleep(500);

            masteringVoice.Dispose();
            xaudio2.StopEngine();
            xaudio2.Dispose();
        }
開發者ID:HakanL,項目名稱:animatroller,代碼行數:86,代碼來源:Program.cs


注:本文中的SharpDX.XAudio2.XAudio2.StopEngine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。