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


C# SoundPlayer.PlayLooping方法代码示例

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


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

示例1: PlayWavFile

        /// <summary>
        /// 播放指定路径的Wav文件
        /// </summary>
        /// <param name="FilePath">Wav路径</param>
        /// <param name="PlayTime">持续播放时间(单位:秒)
        /// <para />
        /// -1:无限地循环播放; 0:只播放一次; 具体正整数:持续循环地播放指定时间
        /// </param>
        public static void PlayWavFile(string FilePath, int PlayTime)
        {
            //增强判断
            if (File.Exists(FilePath) == false)
                return;

            //加载Wav文件
            SoundPlayer Player = new SoundPlayer(FilePath);

            //根据参数执行不同的行为
            if (PlayTime < 0)
                Player.PlayLooping();
            else if (PlayTime == 0)
                Player.Play();
            else
            {
                lock (((ICollection)_playTimeList).SyncRoot)
                {
                    Player.PlayLooping();
                    _playTimeList.Add(new PlayTime
                    {
                        Player = Player,
                        EndTime = DateTime.Now.AddSeconds(PlayTime)
                    });
                }
            }
        }
开发者ID:flyeven,项目名称:Utility,代码行数:35,代码来源:SimpleSoundPlayer.cs

示例2: Start_playing

        public void Start_playing()
        {
            if (_player != null) return;

            _player = new SoundPlayer(@"tada.wav");
            _player.PlayLooping();
        }
开发者ID:kennychou0529,项目名称:NPantaRhei,代码行数:7,代码来源:Soundplayer.cs

示例3: 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

示例4: About

 public About()
 {
     InitializeComponent();
     richTextBox1.Text = text;
     simpleSound = new SoundPlayer(Properties.Resources.about);
     simpleSound.PlayLooping();
 }
开发者ID:remco138,项目名称:amanda,代码行数:7,代码来源:About.cs

示例5: PlayBattleSound

 public static void PlayBattleSound()
 {
     try
     {
         using (SoundPlayer battleSound = new SoundPlayer("..\\..\\Sound\\SoundFiles\\TheBattle.wav"))
         {
             battleSound.PlayLooping();
         }
     }
     catch (FileNotFoundException)
     {
         throw new FileNotFoundException();
     }
     catch (DirectoryNotFoundException)
     {
         throw new DirectoryNotFoundException("The path to the file is incorrect!");
     }
     catch (IOException)
     {
         throw new IOException("Cannot read from file!");
     }
     catch (InvalidOperationException)
     {
         throw new InvalidOperationException();
     }
 }
开发者ID:ivnikolov,项目名称:RPG-Teamwork,代码行数:26,代码来源:Sound.cs

示例6: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            SoundPlayer alersound = new SoundPlayer(@"D:\University\Anul2\Sem2\IDE\FormAps\LOGINApp\LOGINApp\Stranger.wav");

            //Play Sound On Click
            alersound.PlayLooping();
        }
开发者ID:TUM-FAF,项目名称:FAF-121-Barbaros-Nicolae,代码行数:7,代码来源:Form1.cs

示例7: TimesUp

        public TimesUp(String sMaMay, String sInfo, String sTimesIn, String sTimesUp, bool bRing)
        {
            InitializeComponent();
            lbMay.Text = "Máy " + sMaMay;
            lbInfo.Text = sInfo;
            lbTimesIn.Text = "Giờ chơi: " + sTimesIn;
            lbTimesUp.Text = "Giờ nghỉ: " + sTimesUp;

            setSound();

            if (bRing)
            {
                try
                {
                    RingTone = new SoundPlayer(Sound);
                    RingTone.PlayLooping();
                }
                catch
                {
                    //
                }

                timerRing.Enabled = true;
            }
        }
开发者ID:vuchannguyen,项目名称:lg-py,代码行数:25,代码来源:TimesUp.cs

示例8: Play

 public static void Play()
 {
     int rand = World.Rand (0, 5);
     var file = new FileStream (rand + ".wav", FileMode.Open, FileAccess.Read, FileShare.Read);
     player = new SoundPlayer(file);
     player.PlayLooping();
 }
开发者ID:naelstrof,项目名称:2420-DingoDanger,代码行数:7,代码来源:DogSong.cs

示例9: PlayDefaultSoundInLoop

 internal static void PlayDefaultSoundInLoop()
 {
     var streamResourceInfo = Application.GetResourceStream(new Uri("sounds/type.wav", UriKind.Relative));
     if (streamResourceInfo == null) return;
     var player = new SoundPlayer(streamResourceInfo.Stream);
     player.PlayLooping();
 }
开发者ID:hyrmedia,项目名称:PNotes.NET,代码行数:7,代码来源:PNSound.cs

示例10: PlayRepeating

        public void PlayRepeating(string file, string message)
        {
            lock (_alarmSound)
            {
                if (_alarmSound.SoundLocation == "" || _playingOnce)
                {
                    _playingOnce = false;
                    _alarmSound = new SoundPlayer(file);

                    _boxMessage = message;

                    try
                    {
                        _alarmSound.PlayLooping();
                    }
                    catch
                    {
                        // TODO: Logging here
                    }
                    finally
                    {
                        var stopSoundFunction = new ThreadStart(StopSound);
                        var soundStoppingThread = new Thread(stopSoundFunction)
                        {
                            IsBackground = true
                        };
                        soundStoppingThread.Start();
                    }
                }
            }
        }
开发者ID:craftworkgames,项目名称:EagleMonitoringFramework,代码行数:31,代码来源:SoundService.cs

示例11: StartScreen

 public StartScreen()
 {
     InitializeComponent();
     mp3Player = new MP3Player();
     mp3Path = null;
     sp = new SoundPlayer(Resources.Initial_song);
     sp.PlayLooping();
 }
开发者ID:Gago993,项目名称:TriGame,代码行数:8,代码来源:StartScreen.cs

示例12: Form1

 public Form1()
 {
     InitializeComponent();
     score = new Scores();
     dataWords = new Data();
     player = new SoundPlayer(@"../../Resources/Blaues Licht - Afterworld.wav");
     player.PlayLooping();
     Sound = true;
 }
开发者ID:KristijanLaskovski,项目名称:Hangman,代码行数:9,代码来源:Form1.cs

示例13: Play

        public void Play()
        {
            SoundPlayer player = new SoundPlayer(Source);

            using (player)
            {
                player.PlayLooping();
            }
        }
开发者ID:TominaP,项目名称:Fermi-in-the-air,代码行数:9,代码来源:OpeningPage.cs

示例14: FormTitleScreen

 public FormTitleScreen()
 {
     InitializeComponent();
     this.Icon = new Icon("Poker.ico");
     this.StartPosition = FormStartPosition.CenterScreen;
     soundPlayer = new SoundPlayer("BackgroundMusic.wav");
     soundPlayer.PlayLooping();
     btnScore.Hide();
 }
开发者ID:nullcat,项目名称:Texas-Holdem,代码行数:9,代码来源:FormTitleScreen.cs

示例15: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     //Stream str = Application.StartupPath + "\\" + katalogpacjenta + "notatki i nagrania" + listBox1.SelectedItem.ToString();
     if (listBox1.SelectedIndex != -1)
     {
         SoundPlayer simpleSound = new SoundPlayer(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) + "\\Badanie Neurologiczne by Konrad Stawiski\\" + katalogpacjenta + "notatki i nagrania\\" + listBox1.SelectedItem.ToString());
         simpleSound.PlayLooping();
         button3.Enabled = true; button1.Enabled = false;
     }
 }
开发者ID:kstawiski,项目名称:neurexam,代码行数:10,代码来源:NotatkiGlosowe.cs


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