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


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

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


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

示例1: PlayNoise

 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
     }
 }
开发者ID:comcow2007,项目名称:incident-watcher-tool,代码行数:23,代码来源:CurrentIncidentForm.cs

示例2: Beep

 /// <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();
     }
 }
开发者ID:29988122,项目名称:KeyKey,代码行数:26,代码来源:BIStatusBarForm.Notify.cs

示例3: Finish

		}//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))
//.........这里部分代码省略.........
开发者ID:kwedr,项目名称:acdown,代码行数:101,代码来源:FormMain.cs

示例4: Init

        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();
        }
开发者ID:mtomana,项目名称:beatrice,代码行数:26,代码来源:SlideManager.cs

示例5: Ring2

 private void Ring2(object sender,JointIntersectEventArgs e)
 {
     ThreadPool.QueueUserWorkItem(new WaitCallback((_)=>
         {
             var player=new System.Media.SoundPlayer("kick.wav");
             player.PlaySync();
             player.Dispose();
         }));
     return;
 }
开发者ID:abcsharp,项目名称:KinectTestApp,代码行数:10,代码来源:MainWindow.xaml.cs

示例6: Finish

        /// <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();
        }
开发者ID:renning22,项目名称:SnifferPlayer,代码行数:77,代码来源:FormMain.cs

示例7: DragingSay

 /// <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;
 }
开发者ID:moonlightwatch,项目名称:BilibiliGirls,代码行数:21,代码来源:Girl_33.cs

示例8: Say

        /// <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;
        }
开发者ID:moonlightwatch,项目名称:BilibiliGirls,代码行数:25,代码来源:Girl_33.cs

示例9: btnChordH_Click

 private void btnChordH_Click(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(Resources.H1);
     player.Play();
     player.Dispose();
 }
开发者ID:Aleksandra123,项目名称:VP_Songbook,代码行数:6,代码来源:Form1.cs

示例10: playDoneSound

 private static void playDoneSound()
 {
     System.Media.SoundPlayer soundplayer = new System.Media.SoundPlayer("sound.wav");
     soundplayer.Play();
     soundplayer.Dispose();
 }
开发者ID:warcode,项目名称:SC2RAR,代码行数:6,代码来源:Program.cs

示例11: 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


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