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


C# SoundPlayer.LoadAsync方法代码示例

本文整理汇总了C#中System.Media.SoundPlayer.LoadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# SoundPlayer.LoadAsync方法的具体用法?C# SoundPlayer.LoadAsync怎么用?C# SoundPlayer.LoadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Media.SoundPlayer的用法示例。


在下文中一共展示了SoundPlayer.LoadAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: QuickPlay

 /// <summary>
 /// Plays a stream Asychronously using the System.Media.SoundPlayer Object.
 /// </summary>
 /// <param name="S">Any stream, ex: a wav sound resource.</param>
 public void QuickPlay(System.IO.Stream S)
 {
     SoundPlayer wavPlayer = new SoundPlayer();
     wavPlayer.Stream = S;
     wavPlayer.LoadCompleted += new AsyncCompletedEventHandler(wavPlayer_LoadCompleted);
     wavPlayer.LoadAsync();
 }
开发者ID:RickeyWard,项目名称:Rockband-DrumKit-for-Windows,代码行数:11,代码来源:SoundEngine.cs

示例2: Sound

	    public Sound(Stream strm)
	    {
           sound = new SoundPlayer(strm);
           sound.LoadAsync();
           sound.LoadCompleted += sound_LoadCompleted;
           playing = false;
	    }
开发者ID:nlaert,项目名称:Sampler,代码行数:7,代码来源:Sound.cs

示例3: ExerciseView

        // We want to control how depth data gets converted into false-color data
        // for more intuitive visualization, so we keep 32-bit color frame buffer versions of
        // these, to be updated whenever we receive and process a 16-bit frame.
        /*const int RED_IDX = 2;
        const int GREEN_IDX = 1;
        const int BLUE_IDX = 0;
        byte[] depthFrame32 = new byte[320 * 240 * 4];*/
        public ExerciseView(Exercise ex)
        {
            InitializeComponent();

            this.ex = ex;

            statusText.Text = ex.statusMessage;

            passSound = new SoundPlayer("Sounds/ExercisePass.wav");
            passSound.LoadAsync();
            failSound = new SoundPlayer("Sounds/ExerciseFail.wav");
            failSound.LoadAsync();

            #if DEBUG
            lastTime = DateTime.Now;

            fpsLabel = new Label();
            fpsLabel.Content = "FPS:";
            fpsLabel.FontSize = (double)Application.Current.Resources["SmallButtonFont"];
            fpsLabel.HorizontalContentAlignment = HorizontalAlignment.Center;
            fpsLabel.HorizontalAlignment = HorizontalAlignment.Left;
            bottomPanel.Children.Insert(0, fpsLabel);
            #endif

            #if AUDIOUI
            SharedContent.Sr.registerSpeechCommand(SharedContent.Commands.Stop, selectedResponse);
            #endif

            //SharedContent.Nui.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nuiDepthFrameReady);
            SharedContent.Nui.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(nuiSkeletonFrameReady);
            SharedContent.Nui.VideoFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nuiColorFrameReady);
        }
开发者ID:drrobson,项目名称:Group42_FYDP,代码行数:39,代码来源:ExerciseView.xaml.cs

示例4: MainWindow

 internal MainWindow(Archive a)
 {
     InitializeComponent();
       archive = a;
       if(!string.IsNullOrWhiteSpace(archive.settings.sound.backgroundSoundLoc)) {
     main = new SoundPlayer();
     main.SoundLocation = archive.settings.sound.backgroundSoundLoc.RelativeTo(Program.ArchivePath(archive));
     main.PlayLooping();
       }
       if(!string.IsNullOrWhiteSpace(archive.settings.sound.correctSoundLoc)) {
     yes = new SoundPlayer();
     yes.SoundLocation = archive.settings.sound.correctSoundLoc.RelativeTo(Program.ArchivePath(archive));
     yes.LoadAsync();
       }
       if(!string.IsNullOrWhiteSpace(archive.settings.sound.wrongSoundLoc)) {
     no = new SoundPlayer();
     no.SoundLocation = archive.settings.sound.wrongSoundLoc.RelativeTo(Program.ArchivePath(archive));
     no.LoadAsync();
       }
       Text = a.name;
       BackColor = archive.settings.backgroundColor;
       if(!string.IsNullOrWhiteSpace(archive.settings.backgroundLoc)) {
     BackgroundImage = archive.settings.background ?? Extensions.LoadImage(Program.ArchivePath(archive), archive.settings.backgroundLoc);
       }
       Current = new ModeSelect();
 }
开发者ID:svmnotn,项目名称:cuddly-octo-adventure,代码行数:26,代码来源:MainWindow.cs

示例5: start

        /// <summary>
        /// Start the audio playback which will keep the SPDIF link alive.
        /// </summary>
        public void start()
        {

            sound = new SoundPlayer(Properties.Resources.silence);
            sound.LoadCompleted += new AsyncCompletedEventHandler(wavPlayer_LoadCompleted);
            sound.LoadAsync();
            isSoundStarted = true;
        }
开发者ID:IceXPR,项目名称:spdif-ka,代码行数:11,代码来源:AudioControl.cs

示例6: AppTarget

        public AppTarget(UserModel userModel)
        {
            _UserModel = userModel;

            _KeyboardSimulator = new KeyboardSimulator();
            _MouseSimulator = new MouseSimulator();
            _InputDeviceState = new WindowsInputDeviceStateAdaptor();
            _MediaPlayer = new SoundPlayer("letter.wav");
            _MediaPlayer.LoadAsync();
        }
开发者ID:burstas,项目名称:rmps,代码行数:10,代码来源:AppTarget.cs

示例7: AudioPlayer

 public AudioPlayer(string SoundFileName)
 {
     var filePath = Directory.GetCurrentDirectory() + @"\Sounds" + SoundFileName;
             if (! File.Exists(filePath))
                 {
                     return;
                 }
             audiPlayer = new SoundPlayer {SoundLocation = filePath};
             audiPlayer.LoadAsync(); //async, because it could be a big file, and we dont want to lock up the system.
 }
开发者ID:TommyAGK,项目名称:Flex3,代码行数:10,代码来源:AudioPlayer.cs

示例8: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            // Hook up the Elapsed event for the timer.
            int milli = (int)((217f / AV.spectralGraph.Length)* 1000);
            dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, milli);

            wavPlayer = new SoundPlayer();
            wavPlayer.SoundLocation = audiofilename;
            wavPlayer.LoadCompleted += new AsyncCompletedEventHandler(wavPlayer_LoadCompleted);

            dispatcherTimer.Start();
            wavPlayer.LoadAsync();
        }
开发者ID:Graveion,项目名称:AudioSpectrum,代码行数:15,代码来源:Form1.cs

示例9: PreLoadSound

        public static void PreLoadSound(string fileName)
        {
            SoundPlayer sp;
            if (allSounds.TryGetValue(fileName, out sp)) return;

            try {
                allSounds[fileName] = null;
                sp = new SoundPlayer(fileName);
                sp.LoadCompleted += (s, e) => { if( !e.Cancelled && e.Error == null ) allSounds[fileName] = sp; };
                sp.LoadAsync();
            } catch (Exception ex) {
                MessageBox.Show("Error when loading " + fileName + ": " + ex.Message);
                Environment.Exit(0);
            }
        }
开发者ID:benjy3gg,项目名称:PoeHud,代码行数:15,代码来源:Sounds.cs

示例10: CLogic

 public CLogic(MOptions option)
 {
     _SoundPlayer = new SoundPlayer();
     _CNote = new CNote(3);
     LeftShadow = new CShadow(250,150);
     RightShadow = new CShadow(450,150);
     _CMusicHit = new CMusicHit(option.MusicHitFilePath);
     _SoundPlayer.SoundLocation = @option.MusicMediaFilePath;
     //_SoundPlayer.SoundLocation = @"D:\Gangnam.wav";
     _SoundPlayer.LoadAsync();
     _CNote.Speed = _CMusicHit.Speed;
     _TotalTime = _CMusicHit.EndTime;
     Score = 0;
     Progress = 0;
     isStart = false;
 }
开发者ID:lantian2012,项目名称:3DS-GuitarHero,代码行数:16,代码来源:CLogic.cs

示例11: mainScreen

        // constructor
        public mainScreen(int gameId)
        {
            this.gameId = gameId;

            InitializeComponent();
            //territories = new List<Territory>();
            //pictureBox1.Image = Image.FromFile("images/map1.png");

            DrawArea = new Bitmap(Image.FromFile("images/map2.png"));
            //DrawArea = new Bitmap(pictureBox1.Size.Width, pictureBox1.Size.Height);
            pictureBox1.Image = DrawArea;

            yourTurn = false;

            string soundLocation = "sounds/explosion-01.wav";
            player = new SoundPlayer(soundLocation);

            // Load the .wav file.
            player.LoadAsync();
        }
开发者ID:hakonamatata,项目名称:WCF-Risk-Game,代码行数:21,代码来源:mainScreen.cs

示例12: SetSound

      /// <summary>
      /// Adds or replaces a sound by name and file path.
      /// </summary>
      /// <param name="soundName">The name of the sound to load.</param>
      /// <param name="filePath">The path of the sound file.</param>
      /// <returns>True upon error, false otherwise.</returns>
      public static Status SetSound(SoundEffect soundName, string filePath)
      {
         // If the path is bad, 
         if (String.IsNullOrEmpty(filePath) == true || File.Exists(filePath) == false)
         {
            s_log.ErrorFormat("Bad path provided: {0}", filePath);
            return Status.Failure;
         }

         // Make the SoundPlayer and save the sound name as the Tag.
         SoundPlayer player = new SoundPlayer(filePath);
         player.Tag = soundName;

         // Start loading the file.
         s_log.DebugFormat("Starting load of sound {0}.", player.SoundLocation);
         player.LoadCompleted += SoundLoadComplete;
         player.LoadAsync();

         return Status.Success;
      }
开发者ID:Rampant-ai,项目名称:Senesco,代码行数:26,代码来源:SoundUtils.cs

示例13: Add

        /// <summary>
        /// Adds a new wav file to the available sounds for tracking.
        /// </summary>
        /// <param name="soundPath">Full path of the new sound.</param>
        public static void Add(string soundPath)
        {
            var newSound = new FileInfo(soundPath);

            if (!newSound.Exists || !newSound.Extension.Equals(".wav")) return;

            var name = newSound.Name;
            var index = 0;

            while (Sounds.ContainsKey(name))
            {
                name = string.Format("{0}_{1:D3}.wav", name.Remove(-4), index++);
            }

            newSound = newSound.CopyTo(string.Format("{0}\\{1}", SOUND_DIRECTORY, name));
            var sound = new SoundPlayer(newSound.FullName);
            sound.LoadAsync();

            Sounds.Add(name, sound);
        }
开发者ID:LaoArchAngel,项目名称:WRadar,代码行数:24,代码来源:List.cs

示例14: Play

        public static void Play(Button sender, string path)
        {
            var button = sender;

            if (!_playing)
            {
                _sp = new SoundPlayer();
                _sp.Stop();
                _sp.SoundLocation = path;
                _sp.LoadAsync();
                _sp.Play();
                _playing = true;
                button.Content = "Stop";
            }
            else
            {
                _sp.Stop();
                _playing = false;
                button.Content = "Play";
            }
        }
开发者ID:KH8,项目名称:AmpIdent,代码行数:21,代码来源:Player.cs

示例15: Load

        /// <summary>
        /// Loads each of the sounds available for tracking use to memory.
        /// </summary>
        public static void Load()
        {
            // Only load if not yet loaded.
            if (Sounds != null)
                return;

            Sounds = new Dictionary<string, SoundPlayer>();

            var dir = new DirectoryInfo(SOUND_DIRECTORY);

            foreach (var fileInfo in dir.GetFiles("*.wav"))
            {
                var s = new SoundPlayer(fileInfo.FullName);
                s.LoadAsync();

                Sounds.Add(fileInfo.Name, s);
            }

            if (Sounds.Count > 0)
                Default = Sounds.First().Value;
        }
开发者ID:LaoArchAngel,项目名称:WRadar,代码行数:24,代码来源:List.cs


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