本文整理汇总了C#中System.Media.SoundPlayer.Load方法的典型用法代码示例。如果您正苦于以下问题:C# SoundPlayer.Load方法的具体用法?C# SoundPlayer.Load怎么用?C# SoundPlayer.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Media.SoundPlayer
的用法示例。
在下文中一共展示了SoundPlayer.Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AlternatePongExperiment
public AlternatePongExperiment()
{
InitializeComponent();
sensors = new DistanceSensors();
sensors.DistancesChanged += new DistanceSensors.DistancesChangedHandler(sensors_DistancesChanged);
sensors.Connect();
sound1 = new SoundPlayer("sounds/pong.wav"); sound1.Load();
sound2 = new SoundPlayer("sounds/pong2.wav"); sound2.Load();
sound3 = new SoundPlayer("sounds/pong3.wav"); sound3.Load();
paddle1 = 0.5f; paddle2 = 0.5f;
ball = new PointF(DisplayPanel.Width / 2, DisplayPanel.Height / 2);
rand = new Random();
ballSpeed = new PointF((rand.NextDouble() <= 0.5 ? -1 : 1) * BALL_SPEED_FACTOR, (float)(rand.NextDouble() * 2 * BALL_SPEED_FACTOR) - BALL_SPEED_FACTOR);
Task.Factory.StartNew(() =>
{
DateTime startTime = DateTime.Now;
ballStartTimer = BALL_START_TIMER;
while (!IsDisposed)
{
try
{
DateTime currTime = DateTime.Now;
UpdatePositions((float)(currTime - startTime).TotalSeconds);
Invoke(new MethodInvoker(delegate { DisplayPanel.Refresh(); }));
startTime = currTime;
Thread.Sleep(20);
}
catch { }
}
});
}
示例2: Ball
public Ball(Control control, float minX, float maxX, float minY, float maxY, Bat player1, Bat player2, GameState gameState)
: base(control)
{
//Keep a reference to the gamestate around for updating the scores
_gameState = gameState;
//Limits for the ball to bounce
_minX = minX;
_maxX = maxX;
_minY = minY;
_maxY = maxY;
reset(); //Must be called after the limits are set since it uses them!
//The bats to check for collisions with
_player1 = player1;
_player2 = player2;
//Look & feel
control.BackColor = _color;
control.Width = _radius;
control.Height = _radius;
setHeightWidth();
// Create SoundPlayer Object
_beep = new SoundPlayer("beep.wav");
//Preload the sound file
_beep.Load();
}
示例3: EventSetter_Click
private void EventSetter_Click(object sender, RoutedEventArgs e)
{
Debug.Print("EmitClickSound...");
SoundPlayer sp = new SoundPlayer("click.wav");
sp.Load();
sp.Play();
}
示例4: Engine
public Engine(Framework framework)
{
PlaySounds = true;
GameOn = 0;
Players = new List<Player>();
this.framework = framework;
using (Stream wavFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("RoboRallyNet.Resources.Explosion.wav"))
{
explosionPlayer = new SoundPlayer(wavFile);
explosionPlayer.Load();
}
using (Stream wavFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("RoboRallyNet.Resources.laser_blue.wav"))
{
laserPlayer = new SoundPlayer(wavFile);
laserPlayer.Load();
}
using (Stream wavFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("RoboRallyNet.Resources.pit.wav"))
{
pitPlayer = new SoundPlayer(wavFile);
pitPlayer.Load();
}
// create the map
MainMap = GameMap.CreateMap();
}
示例5: play
private void play(String s)
{
System.Media.SoundPlayer sp = new SoundPlayer();
if (s == "start")
{
sp.SoundLocation = "start.wav";
sp.Load();
sp.PlayLooping();
}
else
{
sp.SoundLocation = "stop.wav";
sp.Load();
sp.Play();
}
}
示例6: Init
private void Init()
{
soundplayer = new SoundPlayer {
SoundLocation = filename
};
soundplayer.Load();
}
示例7: Paddle
/// <summary>
/// Initialises paddle of a given size, position and colour.
/// </summary>
/// <param name="paddleSize">the dimensions of the paddle</param>
/// <param name="paddlePosition">the position of the paddle in the game</param>
/// <param name="colour">the colour of the paddle</param>
/// <param name="clientSize">the bounds of the world the paddle exists within</param>
/// <param name="soundFileName">associates a sound with the paddle</param>
public Paddle(Size paddleSize, Point paddlePosition, Color colour, Size clientSize, string soundFileName)
{
this.clientSize = clientSize;
brush = new SolidBrush(colour);
this.paddleSize = paddleSize;
this.paddlePosition = paddlePosition;
collisionSound = new SoundPlayer(soundFileName);
collisionSound.Load();
}
示例8: playSoundEinsatz2
//ChipSound wenn ein Spieler Bet'et
public void playSoundEinsatz2()
{
if (sound)
{
SoundPlayer sp = new SoundPlayer("Sounds/einsatz2.wav");
sp.Load();
sp.Play();
}
}
示例9: playSoundFallen6
//ChipSound am Anfang wenn Karten und Chips an Spieler ausgegeben werden
public void playSoundFallen6()
{
if (sound)
{
SoundPlayer sp = new SoundPlayer("Sounds/chips_fallen6.wav");
sp.Load();
sp.Play();
}
}
示例10: playSoundEinChip2
//ChipSound wenn ein Chip auf den Tisch gezogen wird
public void playSoundEinChip2()
{
if (sound)
{
SoundPlayer sp = new SoundPlayer("Res/Sounds/einchip2.wav");
sp.Load();
sp.Play();
}
}
示例11: playSoundViele1
//ChipSound wenn ein Spieler gewonnen hat
public void playSoundViele1()
{
if (sound)
{
SoundPlayer sp = new SoundPlayer("Sounds/chips_viele1.wav");
sp.Load();
sp.Play();
}
}
示例12: Initialize
public static void Initialize()
{
string windir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
WindowsNotify = new SoundPlayer(windir + "\\Media\\Windows Notify.wav");
WindowsNotify.Load();
WindowsBalloon = new SoundPlayer(windir + "\\Media\\Windows Balloon.wav");
WindowsBalloon.Load();
}
示例13: Client_DownloadFileCompleted
private static void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
_welcomeSound = new SoundPlayer
{
SoundLocation =
SandboxConfig.DataDirectory + @"\OKTR\" + Player.Instance.ChampionName + ".wav"
};
_welcomeSound.Load();
_welcomeSound.Play();
}
示例14: SoundPool
public SoundPool()
{
soundPlayers = new Dictionary<GameSound, SoundPlayer>();
foreach (GameSound soundName in Enum.GetValues(typeof(GameSound)))
{
SoundPlayer player = new SoundPlayer("Sound/" + soundName.ToString() + ".wav");
player.Load();
soundPlayers.Add(soundName, player);
}
}
示例15: Run
public override void Run(PersonalityManager manager, Dictionary<string, string> arguments)
{
if (m_player == null)
{
m_player = new SoundPlayer();
string directory = Path.GetDirectoryName(manager.ActivePersonality.SourceFile);
m_player.SoundLocation = Path.Combine(directory, m_soundFile);
m_player.Load();
}
m_player.Play();
}