コード例 #1
1
 public void PlayNoise(NoiseType Noise)
 {
     //try Make A noise
     try
     {
         if (Noise == NoiseType.NewIncident)
         {
             System.Media.SoundPlayer sp = new System.Media.SoundPlayer("newjob.wav");
             sp.Play();
             sp.Dispose();
         }
         if (Noise == NoiseType.NewAutowatch)
         {
             System.Media.SoundPlayer sp = new System.Media.SoundPlayer("autowatch.wav");
             sp.Play();
             sp.Dispose();
         }
     }
     catch
     {
         //Ahwell, no sound
     }
 }
コード例 #2
0
ファイル: Form2.cs プロジェクト: ume20s/ErecoBlackjack
        private void GameMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            // 閉じたらループBGM終了
            if (playBGMplayer != null)
            {
                playBGMplayer.Stop();
                playBGMplayer.Dispose();
            }

            // セリフ用オブジェクトの破棄
            pl.Dispose();
        }
コード例 #3
0
        public void PlayMusic(string file_url, uint repeat_count)
        {
            if (!File.Exists(file_url))
            {
                return;
            }

            System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer(file_url);

            for (uint index = 0; index < repeat_count; ++index)
            {
                try
                {
                    soundPlayer.PlaySync();
                }

                catch (FileNotFoundException)
                {
                    MessageBox.Show(file_url + "\r\n\r\n음악파일이 존재하지 않습니다.", "오류", 0, MessageBoxIcon.Error);
                    return;
                }

                catch (InvalidOperationException)
                {
                    MessageBox.Show(file_url + "\r\n\r\n올바른 웨이브 음악파일(.wav)이 아닙니다.", "오류", 0, MessageBoxIcon.Error);
                    return;
                }
            }

            soundPlayer.Dispose();
        }
コード例 #4
0
        /// <summary>
        /// 退出事件
        /// </summary>
        private void ScreenForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                tVedio.Stop();
                tVedio.Dispose();

                bg.Dispose();
                myBuffer.Dispose();
                g.Dispose();

                if (sr != null)
                {
                    sr.Close();
                    sr.Dispose();
                }
                if (fstream != null)
                {
                    fstream.Close();
                    fstream.Dispose();
                }

                font.Dispose();
                brush.Dispose();
                if (sound != null)
                {
                    sound.Dispose();
                }
            }
            catch { }
        }
コード例 #5
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     System.Media.SoundPlayer s = new System.Media.SoundPlayer(System.Environment.CurrentDirectory + "\\audio\\shutdown.wav");
     s.PlaySync();
     s.Dispose();
     Application.Current.Shutdown();
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: DeVesen/BazaarWinFrm
        public static void PlayGoodSound()
        {
            var _sp = new System.Media.SoundPlayer(Properties.Resources.Windows_Print_complete);

            _sp.Play();
            _sp.Dispose();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: DeVesen/BazaarWinFrm
        public static void PlayBadSound()
        {
            var _sp = new System.Media.SoundPlayer(Properties.Resources.Windows_Battery_Critical);

            _sp.Play();
            _sp.Dispose();
        }
コード例 #8
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    CloseAndJoin();

                    if (_queue != null)
                    {
                        _queue.Clear();
                        _queue = null;
                    }

                    if (_mediaSoundPlayer != null)
                    {
                        _mediaSoundPlayer.Stop();
                        _mediaSoundPlayer.Dispose();
                        _mediaSoundPlayer = null;
                    }
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: DeVesen/BazaarWinFrm
        public static void PlayConfirmedSound()
        {
            var _sp = new System.Media.SoundPlayer(Properties.Resources.Speech_Sleep);

            _sp.Play();
            _sp.Dispose();
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: EENZEE/WindowsAudioClock
 private void playSound(string path)
 {
     player.SoundLocation = path;
     player.Load();
     player.PlaySync();
     player.Dispose();
 }
コード例 #11
0
ファイル: Game.cs プロジェクト: rogerthat39/minesweeper
        /// <summary>
        /// Displays any mines that were not found, and losing message
        /// </summary>
        /// <param name="ButtonsList">The list of buttons</param>
        /// <param name="mines">An array of the positions (indexes) of the mines</param>
        public static void GameLost(List <Button> ButtonsList, int[] mines)
        {
            ButtonManager bm = new ButtonManager();

            //show position of all mines (excluding those already marked)
            //and show any flags that were put in the wrong place
            for (int i = 0; i < ButtonsList.Count; i++)
            {
                if (mines.Contains(i))
                {
                    //check if there is a flag on the current button
                    if (ButtonsList[i].Image == null)
                    {
                        //show the position of a hidden mine
                        bm.ClickButton(ButtonsList[i]);
                    }
                    //if there's already a flag there (image not null), it's in the correct place, so should not be changed
                }
                else if (ButtonsList[i].Image != null)
                {
                    //if square doesn't contain a bomb and there is a flag there, show the flag was incorrect
                    ButtonsList[i].Image = Image.FromFile("not_bomb.png");
                }
            }

            //play explosion noise
            System.Media.SoundPlayer player = new System.Media.SoundPlayer
            {
                SoundLocation = "bomb.wav"
            };
            player.Play();
            player.Dispose();

            MessageBox.Show("You Lose", "Game Lost");
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: gyuque/CLVShare
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     sndTweet.Dispose();
     sndSuccess.Dispose();
     sndBad.Dispose();
     Process.GetCurrentProcess().Kill(); // Suicide! Just easy and dirty way to kill all threads.
 }
コード例 #13
0
        public void OrderDefend()
        {
            Order = -1;

            System.Media.SoundPlayer player2 = new System.Media.SoundPlayer(@"Sounds\DropSword.wav");
            player2.Play();
            player2.Dispose();
        }
コード例 #14
0
ファイル: BaseSubForm.cs プロジェクト: DeVesen/BazaarWinFrm
        protected void PlayConfirmedSound()
        {
            var _sp = new System.Media.SoundPlayer(Properties.Resources.Speech_Sleep);

            _sp.Play();
            _sp.Dispose();
            _sp = null;
        }
コード例 #15
0
        public void OrderAttack()
        {
            Order = 1;

            System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"Sounds\Swords2.wav");
            player.Play();
            player.Dispose();
        }
コード例 #16
0
ファイル: Form1.cs プロジェクト: ayk24/PaintgameWithKinect
 public void sound()
 {
     //正解サウンド
     System.IO.Stream         strm   = Properties.Resources.correctsound;
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(strm);
     player.PlaySync();
     player.Dispose();
 }
コード例 #17
0
 private void StopBtn_Click(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer();
     //player.SoundLocation = @"C:\Users\acer\Desktop\Things\Music\wav\My Dearest.wav";
     player.Stop();
     player.Dispose();
     Taikotimer.Stop();
 }
コード例 #18
0
ファイル: SoundManager.cs プロジェクト: beldm00/Try
 public void Close()
 {
     if (soundName != null)
     {
         sp.Stop();
         sp.Dispose();
     }
 }
コード例 #19
0
 /// <summary>
 /// Stop a Sound and Dispose of it
 /// </summary>
 public void stopSound(bool dispose)
 {
     _soundPlayer.Stop();
     _playing = false;
     if (dispose == true)
     {
         _soundPlayer.Dispose();
     }
 }
コード例 #20
0
 //再生されている音を止める
 public static void StopSound()
 {
     if (player != null)
     {
         player.Stop();
         player.Dispose();
         player = null;
     }
 }
コード例 #21
0
 private void StopSound()
 {
     if (player != null)
     {
         player.Stop();
         player.Dispose();
         player = null;
     }
 }
コード例 #22
0
ファイル: WinHelper.cs プロジェクト: qqzhw/hcdz-neweagle
 public static void StopPlayWav()
 {
     if (Player == null)
     {
         return;
     }
     Player.Stop();
     Player.Dispose();
 }
コード例 #23
0
 private void Button7_Click(object sender, EventArgs e)
 {
     if (player != null)
     {
         player.Stop();
         player.Dispose();
         player = null;
     }
 }
コード例 #24
0
 /************************************************************************/
 /* 関数名   : apneaCheckedChanged                                      */
 /* 機能     : 無呼吸チェック時のアラーム処理                            */
 /* 引数     : なし                                                      */
 /* 戻り値   : なし														*/
 /************************************************************************/
 public void changeAlarmContents()
 {
     if (player != null)
     {
         stopAlarm();        //停止
         player.Dispose();   //リソース開放
     }
     setAlarm();
 }
コード例 #25
0
 /// <summary>
 /// Plays the WAVE file data contained in the given MemoryStream using the System.Media.SoundPlayer.
 /// </summary>
 /// <param name="memoryStream">The MemoryStream containing the WAVE file data.</param>
 public void PlayWithSoundPlayer(MemoryStream memoryStream)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(memoryStream);
     player.Stream.Seek(0, SeekOrigin.Begin);
     player.PlaySync();
     // TODO: Doesn't support stopping the sound part way through.
     player.Dispose();
     memoryStream.Dispose();
 }
コード例 #26
0
 public void play_click_sound()
 {
     // オーディオリソースを取り出す
     System.IO.Stream strm = Properties.Resources.button_30;
     // 同期再生する
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(strm);
     player.Play();
     // 後始末
     player.Dispose();
 }
コード例 #27
0
 private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
 {
     logger.Debug("Shutdown");
     myTimer.Stop();
     if (soundPlayer != null)
     {
         soundPlayer.Dispose();
     }
     logger.Shutdown();
 }
コード例 #28
0
 private static void PlayWavFile(string wav)
 {
     if (!File.Exists(wav))
     {
         return;
     }
     System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
     sp.SoundLocation = wav;
     sp.Load();
     sp.Play();
     sp.Dispose();
 }
コード例 #29
0
 private void PlayWarningSound()
 {
     var tsk = Task.Run(async() => {
         if (WarningSoundPath != string.Empty)
         {
             var player = new System.Media.SoundPlayer(WarningSoundPath);
             player.Play();
             player.Dispose();
         }
         await Task.Delay(3000);//задержка повтора
     });
 }
コード例 #30
0
 public void Play()
 {
     soundPlayer.Stream.Position = 0L;
     try
     {
         soundPlayer.PlaySync();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "EchoClient Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
     }
     soundPlayer.Dispose();
 }
コード例 #31
0
        // エレ子選択
        private async void PictEreBig_Click(object sender, EventArgs e)
        {
            // エレ子(1)を選択
            mm.chara = 1;

            // ループBGMをとめる
            selectBGMplayer.Stop();
            selectBGMplayer.Dispose();

            // リソースを取得して選択終了BGM再生
            selectBGM.Dispose();
            selectBGM        = new SpStream(Properties.Resources.BGMselect2);
            selectBGM.Volume = sliderVolume.Value;
            selectBGMplayer  = new System.Media.SoundPlayer(selectBGM);
            selectBGMplayer.Play();

            // エレ子よろこんで選択画面終了
            Speach("selectE");
            await EreSelected();

            selectBGMplayer.Dispose();
            this.Close();
        }
コード例 #32
0
 /// <summary>
 /// Alert user with the system default alert sound or customzied
 /// sound clip.
 /// </summary>
 /// <param name="filename">The full path of the sound clip.</param>
 public void Beep(string filename)
 {
     if (filename.Equals("Default") || filename.Length == 0)
     {
         System.Media.SystemSounds.Beep.Play();
     }
     else if (File.Exists(filename))
     {
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(filename);
         try
         {
             player.Play();
         }
         catch { }
         player.Dispose();
     }
     else
     {
         System.Media.SystemSounds.Beep.Play();
     }
 }
コード例 #33
0
ファイル: FormMain.cs プロジェクト: renning22/SnifferPlayer
        /// <summary>
        /// 下载完成(需要判断下载完成还是用户手动停止)
        /// </summary>
        public void Finish(object e)
        {
            //如果需要在安全的线程上下文中执行
            if (this.InvokeRequired)
            {
                this.Invoke(new AcTaskDelegate(Finish), e);
                return;
            }

            ParaFinish p = (ParaFinish)e;
            TaskInfo task = p.SourceTask;
            ListViewItem item = (ListViewItem)task.UIItem;

            //设置完成时间
            task.FinishTime = DateTime.Now;

            //如果下载成功
            if (p.Successed)
            {
                //更新item
                item.SubItems[GetColumn("Status")].Text = task.Status.ToString();
                item.SubItems[GetColumn("Name")].Text = task.Title;
                item.SubItems[GetColumn("Progress")].Text = @"100%"; //下载进度
                item.SubItems[GetColumn("Speed")].Text = ""; //下载速度
                //打开文件夹
                if (Config.setting.OpenFolderAfterComplete)
                    Process.Start(Config.setting.SavePath);
                //播放声音
                if (Config.setting.PlaySound)
                {
                    try
                    {
                        System.Media.SoundPlayer player = new System.Media.SoundPlayer();
                        //优先播放设置文件中的声音(必须是wav格式&忽略大小写)
                        if (File.Exists(Config.setting.SoundFile) && Config.setting.SoundFile.EndsWith(".wav", StringComparison.CurrentCultureIgnoreCase))
                        {
                            player.SoundLocation = Config.setting.SoundFile;
                        }
                        else
                        {
                            //然后播放程序目录下的msg.wav文件
                            if (File.Exists(Path.Combine(Application.StartupPath, "msg.wav")))
                            {
                                player.SoundLocation = Path.Combine(Application.StartupPath, "msg.wav");
                            }
                            else //如果都没有则播放资源文件中的声音文件
                            {
                                player.Stream = Resources.remind;
                            }
                        }
                        player.Load();
                        player.Play();
                        player.Dispose();
                    }
                    catch { }
                }
            }
            else //如果用户取消下载
            {
                if (item != null)
                {
                    //更新item
                    item.SubItems[GetColumn("Status")].Text = task.Status.ToString();
                    item.SubItems[GetColumn("Speed")].Text = ""; //下载速度
                }
            }
            //移除item
            if (lsv.Items.Contains(item))
                if (!IsMatchCurrentFilter(task))
                    lsv.Items.Remove(item);

            //继续下一任务或关机
            ProcessNext();
        }
コード例 #34
0
ファイル: Program.cs プロジェクト: warcode/SC2RAR
 private static void playDoneSound()
 {
     System.Media.SoundPlayer soundplayer = new System.Media.SoundPlayer("sound.wav");
     soundplayer.Play();
     soundplayer.Dispose();
 }
コード例 #35
0
 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;
         }
     }
 }
コード例 #36
0
 private void Ring2(object sender,JointIntersectEventArgs e)
 {
     ThreadPool.QueueUserWorkItem(new WaitCallback((_)=>
         {
             var player=new System.Media.SoundPlayer("kick.wav");
             player.PlaySync();
             player.Dispose();
         }));
     return;
 }
コード例 #37
0
ファイル: Form1.cs プロジェクト: Aleksandra123/VP_Songbook
 private void btnChordH_Click(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(Resources.H1);
     player.Play();
     player.Dispose();
 }
コード例 #38
0
ファイル: SlideManager.cs プロジェクト: mtomana/beatrice
        public static void Init(Player player)
        {
            SoundPlayer = new System.Media.SoundPlayer();
            ClickSoundPlayer = new System.Media.SoundPlayer(Properties.Resources.clickDefault);
            ClickSoundPlayer.Load();

            VolumeSoundPlayer = new System.Media.SoundPlayer(Properties.Resources.clickVolume);
            VolumeSoundPlayer.Load();

            VolumeEndOfScaleSoundPlayer = new System.Media.SoundPlayer(Properties.Resources.cyk);
            VolumeEndOfScaleSoundPlayer.Load();

            EndOfListSoundPlayer = new System.Media.SoundPlayer(Properties.Resources.zium);
            EndOfListSoundPlayer.Load();

            Slides = new List<Slide>();
            SlideManager.playerForm = player;
            playerForm.FormClosed += (s, e) =>
            {
                SlideManager.Dispose();
                SoundPlayer.Dispose();
                ClickSoundPlayer.Dispose();
                VolumeSoundPlayer.Dispose();
            };
            LoadSlidesDefinitions();
        }
コード例 #39
0
        /// <summary>
        /// 说话
        /// </summary>
        /// <returns>说话的文字</returns>
        public string Say()
        {
            Random random = new Random();

            KeyValuePair<string, string> kvp = _wordSoundKvpList[random.Next(_wordSoundKvpList.Count)];

            //启动一个新的线程进行声音播放
            Thread sayThread = new Thread(() =>
            {
                Thread.Sleep(100);
                //检查声音文件的存在性
                if (!string.IsNullOrEmpty(kvp.Value) && File.Exists(kvp.Value))
                {
                    System.Media.SoundPlayer sp = new System.Media.SoundPlayer(kvp.Value);
                    sp.Play();
                    sp.Dispose();
                }
            });
            sayThread.Start();
            return kvp.Key;
        }
コード例 #40
0
ファイル: FormMain.cs プロジェクト: kwedr/acdown
		}//end TipText

		/// <summary>
		/// 下载完成(需要判断下载完成还是用户手动停止)
		/// </summary>
		public void Finish(object e)
		{
			//非UI线程中执行
			ParaFinish p = (ParaFinish)e;
			TaskInfo task = p.SourceTask;
			ListViewItem item = (ListViewItem)task.UIItem;
			//如果下载成功
			if (p.Successed)
			{
				this.Invoke(new MethodInvoker(() =>
				{
					item.SubItems[GetColumn("Status")].Text = task.Status.ToString();
					item.SubItems[GetColumn("Progress")].Text = @"100.00%"; //下载进度
					item.SubItems[GetColumn("Speed")].Text = ""; //下载速度
				}));

				//视频合并 - 
				if (!Tools.IsRunningOnMono &&
					chkAutoCombine.Checked &&
					task.Settings.ContainsKey("VideoCombine"))
				{
					var arr = task.Settings["VideoCombine"].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
					
					if (arr.Length >= 3)
					{
						task.Settings["VideoCombineInProgress"] = "true";
						string output = arr[arr.Length - 1];
						Array.Resize<string>(ref arr, arr.Length - 1);
						var helper = new VideoCombineHelper();
						helper.Combine(arr, output, (o) =>
							{
								this.Invoke(new Action<int>((progress) =>
									{
										item.SubItems[GetColumn("Name")].Text = "正在合并: " + progress.ToString() + "%";
									}), o);
							});
						task.Settings.Remove("VideoCombineInProgress");
					}
				}

				//更新UI
				this.Invoke(new MethodInvoker(() =>
					{
						item.SubItems[GetColumn("Name")].Text = task.Title;
					}));

				//打开文件夹
				if (CoreManager.ConfigManager.Settings.OpenFolderAfterComplete && !Tools.IsRunningOnMono)
					Process.Start(CoreManager.ConfigManager.Settings.SavePath);
				//播放声音
				if (CoreManager.ConfigManager.Settings.PlaySound)
				{
					try
					{
						System.Media.SoundPlayer player = new System.Media.SoundPlayer();
						//优先播放设置文件中的声音(必须是wav格式&忽略大小写)
						if (File.Exists(CoreManager.ConfigManager.Settings.SoundFile) && CoreManager.ConfigManager.Settings.SoundFile.EndsWith(".wav", StringComparison.CurrentCultureIgnoreCase))
						{
							player.SoundLocation = CoreManager.ConfigManager.Settings.SoundFile;
						}
						else
						{
							//然后播放程序目录下的msg.wav文件
							if (File.Exists(Path.Combine(Application.StartupPath, "msg.wav")))
							{
								player.SoundLocation = Path.Combine(Application.StartupPath, "msg.wav");
							}
							else //如果都没有则播放资源文件中的声音文件
							{
								player.Stream = Resources.remind;
							}
						}
						player.Load();
						player.Play();
						player.Dispose();
					}
					catch { }
				}
			}
			else //如果用户取消下载
			{
				if (item != null)
				{
					//更新item
					this.Invoke(new MethodInvoker(() =>
						{
							item.SubItems[GetColumn("Status")].Text = task.Status.ToString();
							item.SubItems[GetColumn("Speed")].Text = ""; //下载速度
						}));
				}
			}
			//移除item
			this.Invoke(new MethodInvoker(() =>
					{
						if (lsv.Items.Contains(item))
							if (!IsMatchCurrentFilter(task))
								lsv.Items.Remove(item);
					}));
		}
コード例 #41
0
 /// <summary>
 /// 被拖拽时呼喊
 /// </summary>
 /// <returns>说话的文字</returns>
 public string DragingSay()
 {
     //启动一个新的线程进行声音播放
     Thread sayThread = new Thread(() =>
     {
         Thread.Sleep(100);
         //检查声音文件的存在性
         if (!string.IsNullOrEmpty(dragingSoundKvp.Value) && File.Exists(dragingSoundKvp.Value))
         {
             System.Media.SoundPlayer sp = new System.Media.SoundPlayer(dragingSoundKvp.Value);
             sp.Play();
             sp.Dispose();
         }
     });
     sayThread.Start();
     return dragingSoundKvp.Key;
 }