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


C# SoundPlayer.Load方法代码示例

本文整理汇总了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 { }
                }
            });
        }
开发者ID:darrenks,项目名称:arduino-ir-distance,代码行数:35,代码来源:AlternatePongExperiment.cs

示例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();
        }
开发者ID:wcardozo,项目名称:TinyTennis,代码行数:30,代码来源:Ball.cs

示例3: EventSetter_Click

 private void EventSetter_Click(object sender, RoutedEventArgs e)
 {
     Debug.Print("EmitClickSound...");
     SoundPlayer sp = new SoundPlayer("click.wav");
     sp.Load();
     sp.Play();
 }
开发者ID:BCProgramming,项目名称:BCJobClock,代码行数:7,代码来源:App.xaml.cs

示例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();
        }
开发者ID:eternalearth888,项目名称:School,代码行数:27,代码来源:Engine.cs

示例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();
     }
 }
开发者ID:lizongying,项目名称:LuckDraw,代码行数:16,代码来源:Form1.cs

示例6: Init

 private void Init()
 {
     soundplayer = new SoundPlayer {
         SoundLocation = filename
     };
     soundplayer.Load();
 }
开发者ID:ralfw,项目名称:CCA_at_the_movies_AppWeckern,代码行数:7,代码来源:Bimmel.cs

示例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();
 }
开发者ID:StephGarland,项目名称:Pong,代码行数:17,代码来源:Paddle.cs

示例8: playSoundEinsatz2

 //ChipSound wenn ein Spieler Bet'et
 public void playSoundEinsatz2()
 {
     if (sound)
     {
         SoundPlayer sp = new SoundPlayer("Sounds/einsatz2.wav");
         sp.Load();
         sp.Play();
     }
 }
开发者ID:SaschaHeyer,项目名称:Poker-PixelSense--Surface-2-,代码行数:10,代码来源:SoundManager.cs

示例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();
     }
 }
开发者ID:SaschaHeyer,项目名称:Poker-PixelSense--Surface-2-,代码行数:10,代码来源:SoundManager.cs

示例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();
     }
 }
开发者ID:B3J4y,项目名称:Poker,代码行数:10,代码来源:SoundManager.cs

示例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();
     }
 }
开发者ID:SaschaHeyer,项目名称:Poker-PixelSense--Surface-2-,代码行数:10,代码来源:SoundManager.cs

示例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();
        }
开发者ID:Mezzuchi,项目名称:MangaEplision,代码行数:10,代码来源:SoundManager.cs

示例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();
 }
开发者ID:FireBuddy,项目名称:EloBuddy-2,代码行数:10,代码来源:OKTRAIO.cs

示例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);
            }
        }
开发者ID:UCSD-HCI,项目名称:RiskBoardGameApp,代码行数:11,代码来源:SoundPool.cs

示例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();
 }
开发者ID:kring,项目名称:Voodoo-Voice,代码行数:11,代码来源:PersonalityActionPlaySound.cs


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