本文整理汇总了C#中System.Media.SoundPlayer.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# SoundPlayer.Dispose方法的具体用法?C# SoundPlayer.Dispose怎么用?C# SoundPlayer.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Media.SoundPlayer
的用法示例。
在下文中一共展示了SoundPlayer.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Play
public void Play(string src)
{
using(SoundPlayer sp = new SoundPlayer(src)) {
sp.PlaySync ();
sp.Dispose ();
}
}
示例2: PlayVoice
public static void PlayVoice(string path)
{
if (File.Exists(path))
{
SoundPlayer player = new SoundPlayer(path);
player.Play();
player.Dispose();
}
}
示例3: ServerStuff
public static void ServerStuff()
{
if (inUse)
{
Console.WriteLine("SERVER ERROR: ALREADY LISTENING IN OTHER THREAD. ABORTING...");
return;
}
else
{
inUse = true;
}
myList = new TcpListener(IPAddress.Any, port);
myList.Start();
Console.WriteLine("Starting at port: " + port);
Console.WriteLine("The local End point is: " +
myList.LocalEndpoint);
Console.WriteLine("Waiting for a connection.....");
s = myList.AcceptSocket();
Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);
SoundPlayer simpleSound2 = new SoundPlayer(@"c:\inmessage.wav");
simpleSound2.Play();
simpleSound2.Dispose();
try
{
while (dflag)
{
byte[] b = new byte[100];
s.Receive(b);
short pick = Convert.ToInt16(b[0]);
if ((pick > 0) && (pick != 127))
{
Console.WriteLine("Got {0}", pick);
ASCIIEncoding asen = new ASCIIEncoding();
try
{
Console.WriteLine("SENDING: " + data[pick - 1].ToString());
}
catch (Exception e)
{
Console.WriteLine(e);
}
s.Send(asen.GetBytes(data[pick - 1].ToString()));
}
else if (pick == 127)
{
inUse = false;
break;
}
}
}
catch { inUse = false; }
s.Close();
myList.Stop();
}
示例4: Close
public void Close()
{
long pos = bw.Seek(0, SeekOrigin.Current);
bw.Seek(0x2a, SeekOrigin.Begin); // chunkDataSizeData
bw.Write((int)(pos - 46));
bw.Seek(0x04, SeekOrigin.Begin); // chunkDataSizeRiff
bw.Write((int)(pos - 8));
bw.Seek(0, SeekOrigin.Begin);
SoundPlayer sp = new SoundPlayer(fs);
sp.PlaySync();
sp.Dispose();
bw.Close();
fs.Close();
}
示例5: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//TakeScreenShot = true;
//snapped = false;
SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.camera_clic_with_flash);
simpleSound.Play();
simpleSound.Dispose();
getScreehShot();
}
示例6: Process
private void Process(int t, int index)
{
for (int i = 0; i < cage[turn].nPieces; i++)
if (cage[turn].Pieces[i].IsChoice)
cage[turn].Pieces[i].IsChoice = false;
SoundPlayer sound = new SoundPlayer(@"Resources\Audio\move.wav");
sound.LoadAsync();
sound.Play();
sound.Dispose();
int count = 0;
while (count < go)
{
count++;
vic = cage[t].Pieces[index].MoveSteponStep(board, index);
if (vic.nType == -2)
{
this.Invoke(new AntiCrossThreadNoArgument(Refresh));
break;
}
if (!this.InvokeRequired)
{
Refresh();
}
else
{
this.Invoke(new AntiCrossThreadNoArgument(Refresh));
}
}
}
示例7: StreamVideo
private void StreamVideo(ImageCodecInfo codecInfo, EncoderParameters encoderParams)
{
MemoryStream m = new MemoryStream(20000);
Bitmap image = null;
IntPtr ip = IntPtr.Zero;
Font fontOverlay = new Font("Times New Roman", 14, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point);
DateTime lastMotion = DateTime.Now;
int interval = 5;
_isRecording = false;
_player = new SoundPlayer();
_player.LoadCompleted += new System.ComponentModel.AsyncCompletedEventHandler((obj, arg) => _player.PlayLooping());
Task.Factory.StartNew(() =>
{
_device.Start();
while (_requested)
{
try
{
// capture image
ip = _device.GetBitMap();
image = new Bitmap(_device.Width, _device.Height, _device.Stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, ip);
image.RotateFlip(RotateFlipType.RotateNoneFlipY);
_currentSensor.ProcessFrame(ref image);
if (_currentSensor.IsAlarming)
{
if (!_isRecording && (DateTime.Now.Second % interval == 0))
_messenger.SendMessage("record");
lastMotion = DateTime.Now;
}
else
{
if (DateTime.Now.Subtract(lastMotion).Seconds > interval)
{
if (_isRecording)
{
_messenger.SendMessage("stop-record");
_isRecording = false;
}
if (_isAlarming)
{
_player.Stop();
_isAlarming = false;
}
}
}
// add text that displays date time to the image
image.AddText(fontOverlay, 10, 10, DateTime.Now.ToString());
// save it to jpeg using quality options
image.Save(m, codecInfo, encoderParams);
// send the jpeg image if server requests it
if (_messenger != null)
_messenger.SendMessage(m.GetBuffer(), MessageType.Image);
}
catch (SocketException)
{
_messenger.Dispose();
_messenger = null;
_requested = false;
}
catch { }
finally
{
// clean up
m.SetLength(0);
if (image != null)
image.Dispose();
if (ip != IntPtr.Zero)
{
Marshal.FreeCoTaskMem(ip);
ip = IntPtr.Zero;
}
}
}
_device.Pause();
_player.Stop();
_player.Dispose();
fontOverlay.Dispose();
disposeReady.Set();
});
}
示例8: Friends_OnFriendOnline
//Separate thread
private void Friends_OnFriendOnline(object sender, FriendInfoEventArgs e)
{
if (InvokeRequired)
{
BeginInvoke(new MethodInvoker(() => Friends_OnFriendOnline(sender, e)));
return;
}
if (!string.IsNullOrEmpty(e.Friend.Name) && !string.IsNullOrEmpty(avname))
{
if (!instance.Config.CurrentConfig.DisableFriendsNotifications)
{
if (instance.Config.CurrentConfig.PlayFriendOnline)
{
SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.Friend_On);
simpleSound.Play();
simpleSound.Dispose();
}
string ttl = "METAbolt Alert";
string body = e.Friend.Name + " is online";
TrayNotifiy(ttl, body, false);
}
}
}
示例9: Self_MoneyBalanceReply
private void Self_MoneyBalanceReply(object sender, MoneyBalanceReplyEventArgs e)
{
if (floading)
{
tmoneybalance = e.Balance;
floading = false;
return;
}
TransactionInfo ti = e.TransactionInfo;
if (ti.DestID != UUID.Zero && ti.SourceID != UUID.Zero)
{
if (instance.Config.CurrentConfig.PlayPaymentReceived)
{
SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.MoneyBeep);
simpleSound.Play();
simpleSound.Dispose();
}
}
//tabs["chat"].Highlight();
int bal = e.Balance - tmoneybalance;
string ttl = "METAbolt Alert";
string body = string.Empty;
if (bal > 0)
{
if (e.Success)
{
if (ti.DestID != client.Self.AgentID)
{
body = e.Description;
}
else
{
if (!String.IsNullOrEmpty(e.Description))
{
string pfrm = string.Empty;
if (ti.TransactionType == 5008)
{
pfrm = " via " + ti.ItemDescription;
}
body = e.Description + pfrm;
body = body.Replace(".", string.Empty);
}
else
{
if (!String.IsNullOrEmpty(ti.ItemDescription))
{
body = "You have received a payment of L$" + ti.Amount.ToString(CultureInfo.CurrentCulture) + " from " + ti.ItemDescription;
}
else
{
body = "You have received a payment of L$" + ti.Amount.ToString(CultureInfo.CurrentCulture);
}
}
}
}
TrayNotifiy(ttl, body, false);
}
else
{
////body = e.Description;
//if (ti.DestID != client.Self.AgentID)
//{
// if (!String.IsNullOrEmpty(ti.ItemDescription))
// {
// body = "You paid L$" + ti.Amount.ToString() + " to/for " + ti.ItemDescription;
// }
// else
// {
// body = "You paid L$" + ti.Amount.ToString();
// }
//}
//else
//{
// body = e.Description;
//}
if (!String.IsNullOrEmpty(e.Description))
{
body = e.Description;
TrayNotifiy(ttl, body, false);
}
}
tmoneybalance = e.Balance;
}
示例10: UpRand
public void UpRand(int x, MyBoard board)
{
if (_curEnd == 0)
board.arrSquares[curIndex].status = 0;
if (x > _curEnd)
{
board.arrEndSquares[nType - 1].empty[_curEnd] = true;
_curEnd = x - 1;
board.arrEndSquares[nType - 1].empty[_curEnd] = false;
_curPoint = board.arrEndSquares[nType - 1].p[_curEnd];
SoundPlayer sound = new SoundPlayer(@"Resources\Audio\UpRand.wav");
sound.LoadAsync();
sound.Play();
sound.Dispose();
if (_curEnd >= 2)
{
int dem = 0;
for (int i = 5; i > _curEnd; i--)
{
if (!board.arrEndSquares[nType - 1].empty[i])
dem++;
}
if (dem == (5 - _curEnd))
this._isFinish = true;
}
}
}
示例11: PlaySound
public static void PlaySound(string file)
{
SoundPlayer player = new SoundPlayer(file);
player.Play();
player.Dispose();
}
示例12: VideoCall_SessionStart_Handler
//开始会话
private void VideoCall_SessionStart_Handler(int roomId)
{
AnyChatCoreSDK.EnterRoom(roomId, "", 0);
SoundPlayer Player = new SoundPlayer();
Player.Stream = Properties.Resources.system;
Player.Play();
Player.Dispose();
}
示例13: DrawSpikes
/// <summary>
/// Update spike waveform window in Spike Scope
/// </summary>
public void DrawSpikes()
{
int i, j;
int numSpikes;
// Clear drawing area and draw simple grid lines
myPanelBuffer.Graphics.Clear(SystemColors.Control);
myPanelBuffer.Graphics.DrawLine(Pens.LightGray, 48, 0, 48, 300);
myPanelBuffer.Graphics.DrawLine(Pens.LightGray, 98, 0, 98, 300);
myPanelBuffer.Graphics.DrawLine(Pens.LightGray, 148, 0, 148, 300);
myPanelBuffer.Graphics.DrawLine(Pens.LightGray, 198, 0, 198, 300);
myPanelBuffer.Graphics.DrawLine(Pens.LightGray, 0, 150, 248, 150);
if (mySpikeRecord.NumSpikesToShow == 0)
numSpikes = 10;
else if (mySpikeRecord.NumSpikesToShow == 1)
numSpikes = 20;
else
numSpikes = 30;
if (mySpikeRecord.SpikeCount < numSpikes)
numSpikes = mySpikeRecord.SpikeCount;
for (i = numSpikes - 1; i >= 0; i--)
{
mySpikeRecord.CopySpikeToArray(spikeSnippet, i);
for (j = 0; j < 61; j++)
{
myPanelBuffer.Graphics.DrawLine(scopePens[mySpikeRecord.NumSpikesToShow, i], (float)(4 * j), 150.0F - YScaleFactors[yScaleIndex] * spikeSnippet[j], (float)(4 * j + 4), 150.0F - YScaleFactors[yScaleIndex] * spikeSnippet[j + 1]);
}
}
// Draw spike detection threshold level
myPanelBuffer.Graphics.DrawLine(Pens.Red, 0.0F, 150.0F - YScaleFactors[yScaleIndex] * mySpikeRecord.GetThreshold(), (float)(4 * 61 + 4), 150.0F - YScaleFactors[yScaleIndex] * mySpikeRecord.GetThreshold());
myPanelBuffer.Render();
if (mySpikeRecord.AudioEnabled)
{
// Generate quick audio wave file of spike in memory
binWaveWriter.Seek(44, SeekOrigin.Begin);
spikeSnippet[0] *= 0.125F;
spikeSnippet[1] *= 0.25F;
spikeSnippet[2] *= 0.5F;
spikeSnippet[3] *= 0.75F;
spikeSnippet[61] *= 0.125F;
spikeSnippet[60] *= 0.25F;
spikeSnippet[59] *= 0.5F;
spikeSnippet[58] *= 0.75F;
float f;
float vol = (float)mySpikeRecord.AudioVolume;
for (int k = 0; k < 62; k++)
{
f = vol * vol * 10.0F * spikeSnippet[k];
if (f > 32767.0F)
f = 32767.0F;
else if (f < -32767.0F)
f = -32767.0F;
binWaveWriter.Write((Int16)f);
}
binWaveWriter.Seek(0, SeekOrigin.Begin);
// Play wave file of spike from memory
SoundPlayer smallSoundPlayer = new SoundPlayer();
smallSoundPlayer.Stream = memWave;
smallSoundPlayer.Load();
smallSoundPlayer.Play();
smallSoundPlayer.Dispose();
}
}
示例14: VideoCall_Request_Handler
//接收到视频呼叫请求处理
private void VideoCall_Request_Handler(int dwUserId, int dwParam, string lpUserStr)
{
if (this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
timer_call.Stop();//关闭计时器,确认状态
ConversationMode = new ConversationInfo();
ConversationMode.SuserId = dwUserId;
ConversationMode.TuserId = m_UserId;
UserInfo userItem = GetUserInfoByUserId(dwUserId);
if (userItem != null)
{
ShowCallMessage(Properties.Resources._14, userItem.Name + "向您发起视频会话邀请...");
Button btn_accepted = new Button();
btn_accepted.Font = new Font("微软雅黑", 20);
btn_accepted.Size = new Size(140, 50);
btn_accepted.Location = new Point(pan_call.Width / 2 - btn_accepted.Width - 10, pic_call.Top + pic_call.Height + 30);
btn_accepted.Text = "接受";
btn_accepted.Tag = "btn";
btn_accepted.BackColor = Color.Lime;
btn_accepted.ForeColor = Color.White;
btn_accepted.Click += new EventHandler(btn_accepted_Click);
pan_call.Controls.Add(btn_accepted);
Button btn_refuse = new Button();
btn_refuse.Font = new Font("微软雅黑", 20);
btn_refuse.Size = new Size(140, 50);
btn_refuse.Location = new Point(pan_call.Width / 2 + 10, pic_call.Top + pic_call.Height + 30);
btn_refuse.Text = "拒绝";
btn_refuse.Tag = "btn";
btn_refuse.BackColor = Color.Red;
btn_refuse.ForeColor = Color.White;
btn_refuse.Click += new EventHandler(btn_refuse_Click);
pan_call.Controls.Add(btn_refuse);
SoundPlayer Player = new SoundPlayer();
Player.Stream = Properties.Resources.ring;
Player.Play();
Player.Dispose();
}
}
示例15: VideoCall_WaitCall_Handler
//呼叫等待
private void VideoCall_WaitCall_Handler()
{
try
{
intCallTimer = 60;
ShowCallMessage(Properties.Resources._15, "呼叫请求中,等待用户响应...");
//timer_call.Start();
timer_call.Stop();//关闭计时器,确认状态
Button btn_cancall = new Button();
btn_cancall.Font = new Font("微软雅黑", 20);
btn_cancall.Size = new Size(140, 50);
btn_cancall.Location = new Point(pan_call.Width / 2 - btn_cancall.Width / 2, pic_call.Top + pic_call.Height + 30);
btn_cancall.Text = "取消";
btn_cancall.Tag = "btn";
btn_cancall.BackColor = Color.Red;
btn_cancall.ForeColor = Color.White;
btn_cancall.Click += new EventHandler(btn_cancall_Click);
pan_call.Controls.Add(btn_cancall);
SoundPlayer Player = new SoundPlayer();
Player.Stream = Properties.Resources.ring;
Player.Play();
Player.Dispose();
}
catch (Exception ex)
{
Log.SetLog("VideoChat.Hall.WaitCall WaitCall:" + ex.Message.ToString());
}
}