本文整理汇总了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)
});
}
}
}
示例2: Start_playing
public void Start_playing()
{
if (_player != null) return;
_player = new SoundPlayer(@"tada.wav");
_player.PlayLooping();
}
示例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();
}
示例4: About
public About()
{
InitializeComponent();
richTextBox1.Text = text;
simpleSound = new SoundPlayer(Properties.Resources.about);
simpleSound.PlayLooping();
}
示例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();
}
}
示例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();
}
示例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;
}
}
示例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();
}
示例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();
}
示例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();
}
}
}
}
示例11: StartScreen
public StartScreen()
{
InitializeComponent();
mp3Player = new MP3Player();
mp3Path = null;
sp = new SoundPlayer(Resources.Initial_song);
sp.PlayLooping();
}
示例12: Form1
public Form1()
{
InitializeComponent();
score = new Scores();
dataWords = new Data();
player = new SoundPlayer(@"../../Resources/Blaues Licht - Afterworld.wav");
player.PlayLooping();
Sound = true;
}
示例13: Play
public void Play()
{
SoundPlayer player = new SoundPlayer(Source);
using (player)
{
player.PlayLooping();
}
}
示例14: FormTitleScreen
public FormTitleScreen()
{
InitializeComponent();
this.Icon = new Icon("Poker.ico");
this.StartPosition = FormStartPosition.CenterScreen;
soundPlayer = new SoundPlayer("BackgroundMusic.wav");
soundPlayer.PlayLooping();
btnScore.Hide();
}
示例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;
}
}