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


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

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


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

示例1: PlayWav

 private static void PlayWav(string wavFile)
 {
     Task.Run(() =>
     {
         var player = new System.Media.SoundPlayer {SoundLocation = wavFile};
         player.PlaySync();
     });
 }
开发者ID:prom3theu5,项目名称:iNGEN-Ark-RCON-Desktop,代码行数:8,代码来源:SoundManager.cs

示例2: Play

 public static void Play(Sonidos sonido)
 {
     byte[] musica = Obtener(sonido.ToString());
     string pathSonido;
     //play sonido
     pathSonido = DameRutaTemporal(musica,sonido.ToString());
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(pathSonido);
     player.PlaySync();
 }
开发者ID:tetradog,项目名称:ZinLock,代码行数:9,代码来源:SonidosZinLock.cs

示例3: PlaySound

 public static void PlaySound(ConfigurationProfile profile)
 {
     if (profile.SoundEnabled.IsTrue())
     {
         using (var p = new System.Media.SoundPlayer())
         {
             p.SoundLocation = Path.Combine(Globals.ExecutableDirectory, profile.Soundfile);
             p.PlaySync();
         }
     }
 }
开发者ID:mard,项目名称:Uploader,代码行数:11,代码来源:Common.cs

示例4: Main

 public static void Main(string[] args)
 {
     bool infinito = args[1] == "-i";
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(args[0]);
     Console.WriteLine("Plaing:"+args[0]);
     if (!infinito)
         player.PlaySync();
     else{
         player.PlayLooping();
         for(;;);
     }
 }
开发者ID:tetradog,项目名称:ZinLock,代码行数:12,代码来源:Program.cs

示例5: PlayAsync

 public void PlayAsync(string url)
 {
     System.Threading.EventWaitHandle wait = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.AutoReset);
     Task.Factory.StartNew(() =>
     {
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(url);
         player.PlaySync();
         wait.Set();
     }).ContinueWith(x =>
     {
         wait.WaitOne();
     });
 }
开发者ID:sandalkuilang,项目名称:texto,代码行数:13,代码来源:SoundPlayer.cs

示例6: Fisished

        public void Fisished()
        {
            btStart.Text = "Start";
            btStopReset.Text = "Reset";

            IndicatorOn(false);
            CDTimer.Enabled = false;
            TimeToCountDown.Clear();
            DisplayRefesh();

            int sel = Properties.Settings.Default.WavFileSelected;
            string location = CDCControls.WavLocation[sel];
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(location);

            for (int i = 0; i < Properties.Settings.Default.WavPlayTimes; i++)
            {
                player.PlaySync();
            }
        }
开发者ID:ReneeHuh,项目名称:CountDownClock,代码行数:19,代码来源:Form1.cs

示例7: PlayCachedSound

        public static void PlayCachedSound(this UnmanagedMemoryStream resource)
        {
            if (ReferenceEquals(SoundCache, null))
                SoundCache = new Dictionary<int, MemoryStream>();

            if (!SoundCache.ContainsKey(resource.GetHashCode()))
            {
                resource.Position = 0;
                SoundCache.Add(resource.GetHashCode(),
                    new MemoryStream(new BinaryReader(resource).ReadBytes((int)resource.Length))
                );
            }

            System.Media.SoundPlayer sp = new System.Media.SoundPlayer(SoundCache[resource.GetHashCode()]);
            try { sp.PlaySync(); }
            catch { }
            finally
            {
                sp = null;
                SoundCache[resource.GetHashCode()].Position = 0;
            }
        }
开发者ID:IsaacSanch,项目名称:KoruptLib,代码行数:22,代码来源:SoundPlayer.cs

示例8: beep

        /// <summary>
        /// Emet un bip.
        /// </summary>
        public void beep()
        {
            //Il faut que le bot ne soit pas en train de se déconnecter pour émettre un bip
            if (!this.IsLoggingOut)
            {
                System.Media.SoundPlayer spBeep = new System.Media.SoundPlayer(Path.Combine(Logging.ApplicationPath, Classes.Updater.strPluginPath + "Sounds\\beep.wav"));
                spBeep.PlaySync();
                spBeep.PlaySync();
            }

        }
开发者ID:Borgsen,项目名称:celisuis-honorbuddy-pack,代码行数:14,代码来源:LogMeOut.cs

示例9: SAY

        private void SAY(string content)
        {
            string[] lines;
            #region decide emotion
            //get current emotion
            Console.WriteLine("EMOTION?");
            emotion = Console.ReadLine();

            //if emotion doesn't exist, set it to empty
            if (emotion == "EMOTION")
            {
                emotion = "";
            }

            //load emotion settings
            try
            {
                lines = System.IO.File.ReadAllLines(Environment.CurrentDirectory + @"\EMOTION.txt");
            }
            catch
            {
                Console.WriteLine(@"ERR(Unable to load the emotion settings. [PNGUI])");
                Console.Out.Flush();
                return;
            }

            //decide emotion
            int numline = 1;
            foreach (string line in lines)
            {
                if (line.Trim() != "" || !line.StartsWith("#")) //allows some formatting
                {
                    string[] separators = { "," };
                    string[] entry = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    try
                    {
                        if (emotion == entry[0])
                        {
                            silent_animation = entry[1];
                            talk_animation = entry[2];
                            File.WriteAllText(Environment.CurrentDirectory + @"\spchGen.bat", "cd %~dp0\n" + entry[3]);
                        }
                    }
                    catch
                    {
                        Console.WriteLine(@"ERR(Unable to parse line " + numline.ToString() + " of the emotion settings. [PNGUI])");
                    }
                }
                numline++;
            }

            #endregion

            #region coordinate animation
            foreach (string part in content.Split(new char[] { '、', ' ', '\t' }))
            {
                if (part.Trim() != "")
                {
                    //Generate speech wav
                    GenSpeech(part);

                        if (!noAnimation)
                        {
                            ANIMATE(talk_animation);
                            using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\output.wav"))
                            {
                                player.PlaySync();
                            }
                            ANIMATE(silent_animation);
                        }
                        else
                        {
                            using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\output.wav"))
                            {
                                player.Play();
                            }
                        }

                }

            }

            #endregion
        }
开发者ID:harry159821,项目名称:PNG-UI,代码行数:84,代码来源:Form1.cs

示例10: PlaySound

 private void PlaySound() {
     //オーディオリソースを取り出す
     using (System.IO.Stream strm = Properties.Resources.sound1) {
         //同期再生する
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(strm);
         player.PlaySync();
     }
 }
开发者ID:lvojp,项目名称:bloodSugarLevelMeter,代码行数:8,代码来源:Form1.cs

示例11: PlaySound

        private void PlaySound()
        {
            string wavPath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), WavFileUriPath);
            Uri uri = new Uri(wavPath);
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(WavFileUriPath);
            player.PlaySync();

            this.Dispatcher.Invoke((Action)(() =>
            {
                recordGrid.Visibility = System.Windows.Visibility.Visible;
                recordingdGrid.Visibility = System.Windows.Visibility.Hidden;

                DisplayAnalysis();
            }));
        }
开发者ID:MicrosoftDXGermany,项目名称:more-personal-computing,代码行数:15,代码来源:MainWindow.xaml.cs

示例12: TellString

        /// <summary>
        /// Reads aloud string passed in parameter. Automatically detects available syllables or word parts from data direcory (Path is specified in DATA_PATH constant).
        /// </summary>
        /// <param name="input">String used as for slovak reading routine.</param>
        public static void TellString(string input)
        {
            List<string> syllables = new List<string>();

            DirectoryInfo directory = new DirectoryInfo(DATA_PATH);

            foreach (FileInfo file in directory.GetFiles("*.wav"))
            {
                if (file.Name.Substring(0, file.Name.Length - file.Extension.Length) != SPACE_NAME) syllables.Add(file.Name.Substring(0, file.Name.Length - file.Extension.Length));
            }

            Queue<string> readingQueue = new Queue<string>();

            foreach (string word in input.Replace("q", "k").Replace("w", "v").Replace("ä","e").Replace("nn","n").Replace(":",".").ToLower().Split(' '))
            {
                string wordPart = word;
                while (wordPart != "")
                {
                    string longestSyllable = "";
                    foreach (string syllable in syllables)
                    {
                        if (wordPart.StartsWith(syllable) && syllable.Length > longestSyllable.Length) longestSyllable = syllable;
                    }
                    if (longestSyllable == "") break;
                    readingQueue.Enqueue(longestSyllable);
                    wordPart = wordPart.Remove(0, longestSyllable.Length);
                }
                readingQueue.Enqueue(SPACE_NAME);
            }

            System.Media.SoundPlayer player = new System.Media.SoundPlayer();

            while (readingQueue.Count > 0)
            {
                player.SoundLocation = DATA_PATH + readingQueue.Dequeue() + ".wav";
                player.PlaySync();
            }
        }
开发者ID:apancik,项目名称:SSKTTS,代码行数:42,代码来源:ssktts_source.cs

示例13: SAY

        private void SAY(int id, string content)
        {
            string[] lines;
            #region decide emotion
            //get current emotion
            Console.WriteLine("EMOTION?");
            emotion = Console.ReadLine();

            //if emotion doesn't exist, set it to empty
            if (emotion == "EMOTION")
            {
                emotion = "";
            }

            //load emotion settings
            try
            {
                lines = System.IO.File.ReadAllLines(Environment.CurrentDirectory + @"\EMOTION.txt");
            }
            catch
            {
                Console.WriteLine(@"ERR(Unable to load the emotion settings. [PNGUI])");
                Console.Out.Flush();
                return;
            }

            //decide emotion
            int numline = 1;
            foreach (string line in lines)
            {
                if (line.Trim() != "" || !line.StartsWith("#")) //allows some formatting
                {
                    string[] separators = { "," };
                    string[] entry = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    try
                    {
                        if (emotion == entry[0])
                        {
                            File.WriteAllText(Environment.CurrentDirectory + @"\spchGen.bat", "cd %~dp0\n" + entry[1]);
                        }
                    }
                    catch
                    {
                        Console.WriteLine(@"ERR(Unable to parse line " + numline.ToString() + " of the emotion settings. [PNGUI])");
                    }
                }
                numline++;
            }

            #endregion

            int length;
            #region coordinate animation
            foreach (string part in content.Split(new char[] { '、', ' ', '\t' }))
            {
                if (part.Trim() != "")
                {

                    //Generate speech wav
                    length = GenSpeech(part);

                    if (length == 0) { return; }

                    //float[] amps = AmplitudesFromFile(Environment.CurrentDirectory + @"\res\sound\speech.wav");

                    if (!noAnimation)
                    {
                        Console.WriteLine(@"UI_PlaySound(res\sound\speech.wav," + id + ")");
                        System.Threading.Thread.Sleep(length);
                    }
                    else
                    {
                        using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\res\sound\speech.wav"))
                        {
                            player.PlaySync();
                        }
                    }
                    Console.WriteLine("UI_SetMouthOpen(0," + id + ")");

                }

            }

            #endregion
        }
开发者ID:Ikari2015,项目名称:Live2D,代码行数:85,代码来源:Form1.cs

示例14: PlayInternal

 protected virtual void PlayInternal(string path)
 {
     System.Media.SoundPlayer soundPlayer = null;
     try
     {
         soundPlayer = new System.Media.SoundPlayer(path);
         soundPlayer.PlaySync();
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex);
     }
     finally
     {
         if (null != soundPlayer)
         {
             soundPlayer.Dispose();
             soundPlayer = null;
         }
     }
 }
开发者ID:kaijin-games,项目名称:larning-english-game,代码行数:21,代码来源:EPuzzleSoundPlayer.cs

示例15: Fisished

        public void Fisished()
        {
            Timer.Enabled = false;
            Time.Clear();

            TimeChangedEventArgs e = new TimeChangedEventArgs(Time.ToString());
            DelegateExpansion.CrossInvoke(CountDownChanged, this, e);
            //CountDownChanged(this,e) ;

            int sel = Properties.Settings.Default.WavFileSelected;
            string location = CDCControls.WavLocation[sel];
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(location);

            for (int i = 0; i < Properties.Settings.Default.WavPlayTimes; i++)
            {
                player.PlaySync();
            }
        }
开发者ID:ReneeHuh,项目名称:CountDownClock,代码行数:18,代码来源:CountDown.cs


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