本文整理汇总了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
}
}
示例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();
}
}
示例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))
//.........这里部分代码省略.........
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例10: playDoneSound
private static void playDoneSound()
{
System.Media.SoundPlayer soundplayer = new System.Media.SoundPlayer("sound.wav");
soundplayer.Play();
soundplayer.Dispose();
}
示例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;
}
}
}