本文整理汇总了C#中System.Media.SoundPlayer.Play方法的典型用法代码示例。如果您正苦于以下问题:C# System.Media.SoundPlayer.Play方法的具体用法?C# System.Media.SoundPlayer.Play怎么用?C# System.Media.SoundPlayer.Play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Media.SoundPlayer
的用法示例。
在下文中一共展示了System.Media.SoundPlayer.Play方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LaserSound
public void LaserSound()
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = "peww1.wav";
player.Load();
player.Play();
player.Play();
}
示例2: refreshControls
public void refreshControls()
{
lblTurno.Invoke((MethodInvoker)(() => lblTurno.Text = String.Format("{0}", turnosModel.TurnoActual.Turno.ToString())));
lblVentanilla.Invoke((MethodInvoker)(() => lblVentanilla.Text = String.Format("{0}", turnosModel.TurnoActual.Ventanilla.ToString())));
short iter = 0;
if (turnosModel.TurnosAtendiendo.Count() != 0)
{
foreach (turno item in (turnosModel.TurnosAtendiendo.Count() == 1 ? turnosModel.TurnosAtendiendo : turnosModel.TurnosAtendiendo.GetRange(turnosModel.TurnosAtendiendo.Count() - 2, 2)))
{
if (iter == 0)
{
lblTurno1Atiende.Invoke((MethodInvoker)(() => lblTurno1Atiende.Text = String.Format("{0}", item.Turno.ToString())));
lblVentanilla1Atiende.Invoke((MethodInvoker)(() => lblVentanilla1Atiende.Text = String.Format("{0}", item.Ventanilla.ToString())));
lblServicio1Atiende.Invoke((MethodInvoker)(() => lblServicio1Atiende.Text = String.Format("{0}", item.Tramite.ToString())));
}
else
{
lblTurno2Atiende.Invoke((MethodInvoker)(() => lblTurno2Atiende.Text = String.Format("{0}", item.Turno.ToString())));
lblVentanilla2Atiende.Invoke((MethodInvoker)(() => lblVentanilla2Atiende.Text = String.Format("{0}", item.Ventanilla.ToString())));
lblServicio2Atiende.Invoke((MethodInvoker)(() => lblServicio2Atiende.Text = String.Format("{0}", item.Tramite.ToString())));
}
iter++;
}
}
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = string.Format("{0}\\{1}{2}", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"Assets\Sounds\", "defaultSound.wav");
player.Play();
}
示例3: playSound
private void playSound(string path)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = path;
player.Load();
player.Play();
}
示例4: Main
static void Main(string[] args)
{
string dave = "\u0044\u0061\u0076\u0065";
Console.WriteLine("Hello, " + dave + ".");
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("\aAre You Trying To Turn ME Off ?");
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("\aAre You Still Trying\a To Leave ME " + dave + " ?!\a");
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("I'm sorry " + dave + ", I'm afraid I can't do that.");
System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
//Just change the first part of this to wherever the Hello_Wold folder is on your Drive
myPlayer.SoundLocation = @"J:\Homework\CSC202\Hello_World\Hello_World\SorryDave.wav";
myPlayer.Play();
Console.WriteLine("Press any key to");
Console.WriteLine("\t\tKiLL ");
Console.Write("\t\t HAL");
Console.ReadKey(true);
}
示例5: ShowAwooga
public void ShowAwooga()
{
var player = new System.Media.SoundPlayer { SoundLocation = _config.Wav };
player.Play();
var awooga = new AwoogaForm(_config.Image);
awooga.ShowDialog();
}
示例6: controllerActivated
public override void controllerActivated(Dictionary<int, Target> targets)
{
System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
myPlayer.SoundLocation = @"C:\Users\jon\AppData\Local\Temp\Temp2_P3StarterCode.zip\P3StarterCode\coin.wav";
myPlayer.LoadAsync();
myPlayer.Play();
}
示例7: PlaySound
public void PlaySound(string soundLocation, int volume)
{
if (string.IsNullOrEmpty(soundLocation)) return;
try
{
Log.DebugFormat("Playing sound '{0}' at volume", soundLocation, volume);
try
{
if (currentWaveOutVolume == null || currentWaveOutVolume.Value != volume)
{
int newVolume = ((ushort.MaxValue / 100) * volume);
uint newVolumeAllChannels = (((uint)newVolume & 0x0000ffff) | ((uint)newVolume << 16)); //Set the volume on left and right channels
PInvoke.waveOutSetVolume(IntPtr.Zero, newVolumeAllChannels);
currentWaveOutVolume = volume;
}
}
catch (Exception exception)
{
var customException = new ApplicationException(
string.Format("There was a problem setting the wave out volume to '{0}'", volume), exception);
PublishError(this, customException);
}
var player = new System.Media.SoundPlayer(soundLocation);
player.Play();
}
catch (Exception exception)
{
PublishError(this, exception);
}
}
示例8: btPlay_Click
private void btPlay_Click(object sender, EventArgs e)
{
int sel = Convert.ToInt32(listboxWavSlection.SelectedIndex);
string location = CDCControls.WavLocation[sel];
System.Media.SoundPlayer player = new System.Media.SoundPlayer(location);
player.Play();
}
示例9: Controller
songbookEntities2 testcontext; //
#endregion Fields
#region Constructors
public Controller(Panel[] panels, ListBox _lbSongs, ComboBox _cbShowCategory, ComboBox _cbAddSongCategory, ListBox _lbRemoveSong)
{
Panels = panels;
lbSongs = _lbSongs;
cbShowCategory = _cbShowCategory;
cbAddSongCategory = _cbAddSongCategory;
lbRemoveSong = _lbRemoveSong;
currentCategory = -1;
ShowPanel(0); // иницијално ги сокриваме сите панели
Panels[1].Hide(); //како и панелот со мени
Graph = Panels[0].CreateGraphics(); //платно за исцртување на интро панелот
buffBmp = new Bitmap(Panels[0].Width, Panels[0].Height); //
buffGraph = Graphics.FromImage(buffBmp); //платно кое го користиме како бафер
numbSteps = 0;
backgColor = Color.FromArgb(250, 250, 200); // позадинска боја на интрото
//креирање на четки и фонтови
brushBlue = new SolidBrush(Color.Blue);
brushDodgerBlue = new SolidBrush(Color.DodgerBlue);
brushRed = new SolidBrush(Color.Red);
font1 = new Font("Arial", 30);
font2 = new Font("Arial", 20);
font3 = new Font("Arial", 16);
testcontext = new songbookEntities2();
loadIntro();
// стартување тајмерот
loadTimer = new Timer();
loadTimer.Interval = 50;
loadTimer.Tick += new EventHandler(timer_Tick);
loadTimer.Start();
// стартување на интро звукот
System.Media.SoundPlayer player = new System.Media.SoundPlayer(Resources.intro);
player.Play();
}
示例10: TagVisualization_Initialized
private void TagVisualization_Initialized(object sender, EventArgs e)
{
String appdir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
var path = System.IO.Path.Combine(appdir, "camera-shutter-click-01.wav");
System.Media.SoundPlayer player = new System.Media.SoundPlayer(path);
player.Play();
}
示例11: SearchandDestroy
public int SearchandDestroy(bool reset)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.kachu);
System.Media.SoundPlayer playerInf = new System.Media.SoundPlayer(Properties.Resources.pikapika);
TargetManager tm = TargetManager.GetInstance();
Controller controller = Controller.GetInstance();
int i = 0;
foreach (Target target in tm.TMTargets)
{
i++;
controller.MoveTo(target.x, target.y);
player.Play();
controller.Fire();
controller.SetNum(controller.GetNum() - 1);
playerInf.PlayLooping();
if (i != tm.TMTargets.Count)
{
if (reset == true)
{
controller.Launcher.Reset();
}
}
Thread.Sleep(250);
}
return i;
}
示例12: Main
static void Main(string[] args)
{
if (Convert.ToInt32(args[0]) == -1)
{
string soundsRoot = @"I:\ORT_Pendrive\Proyecto\TaskExecute\TaskExecute\bin\Debug\music";
Random rand = new Random();
var soundFiles = Directory.GetFiles(soundsRoot, "*.wav");
var playSound = soundFiles[rand.Next(0, soundFiles.Length)];
System.Media.SoundPlayer player = new System.Media.SoundPlayer(playSound);
if (args[1] == "T")
{
player.Play();
}
else
{
player.Stop();
}
Console.Read();
}
else
{
int output = Convert.ToInt32(Math.Pow(2, Convert.ToInt32(args[0])));
int total = PortControl.PortControl.Input(888);
if (args[1] == "T")
{
if (((byte)PortControl.PortControl.Input(888) & (byte)output) == (byte)0)
PortControl.PortControl.Output(888, total + output);
}
else
if (((byte)PortControl.PortControl.Input(888) & (byte)output) == output)
PortControl.PortControl.Output(888, total - output);
Environment.Exit(0);
}
}
示例13: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = "Sound.wav";
player.Play();
}
示例14: PlaySound
public static void PlaySound(string soundpath)
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
try
{
player.SoundLocation = soundpath;
player.Play();
}
catch
{
MessageBox.Show("Failed to play custom sound");
player.SoundLocation = "Resources/alarm_beep.wav";
player.Play();
}
}
示例15: EndGame
static void EndGame()
{
player = new System.Media.SoundPlayer("crash.wav");
player.Play();
for (int i = 0; i < 3; i++)
{
Console.BackgroundColor = ConsoleColor.Red;
Console.Clear();
System.Threading.Thread.Sleep(200);
Console.BackgroundColor = ConsoleColor.Yellow;
Console.Clear();
System.Threading.Thread.Sleep(200);
}
Console.ForegroundColor = ConsoleColor.Red;
Console.SetCursorPosition(35, 10);
Console.WriteLine(@"
_______ _______ __ __ _______ _______ __ __ _______ ______
| || _ || |_| || | | || | | || || _ |
| ___|| |_| || || ___| | _ || |_| || ___|| | ||
| | __ | || || |___ | | | || || |___ | |_||_
| || || || || ___| | |_| || || ___|| __ |
| |_| || _ || ||_|| || |___ | | | | | |___ | | | |
|_______||__| |__||_| |_||_______| |_______| |___| |_______||___| |_| ");
}