本文整理汇总了C#中Sound.Play方法的典型用法代码示例。如果您正苦于以下问题:C# Sound.Play方法的具体用法?C# Sound.Play怎么用?C# Sound.Play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sound
的用法示例。
在下文中一共展示了Sound.Play方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlaySound
/// <summary>
/// Plays a sound by name.
/// </summary>
/// <param name="soundName">The sound to play</param>
public void PlaySound(Sound sound, bool isSoundOff, bool isPauseMusicZune)
{
if (isSoundOff || !isPauseMusicZune)
return;
// If the sound exists, start it
sound.Play();
}
示例2: PlaySound
private void PlaySound(string soundFile)
{
// sanitize path
string path = soundFile;
if (!Path.IsPathRooted(path))
{
path = System.Environment.CurrentDirectory + Path.DirectorySeparatorChar + path;
}
// play sound
Sound sound = new Sound();
sound.Play(path);
}
示例3: Level2
public Level2(TimeGuardianGame game, int lives)
: base(game)
{
Game = game;
BackgroundCreator();
_tileMap = FileReader.levelMaker(_levelNr, UtilStrings.TilesX, UtilStrings.TilesY);
Player = new Player(lives, this, Game);
_enemy = new EnemyOwl(this);
CreateLevel();
AddChild(Player);
AddChild(_enemy);
Music = new Sound(UtilStrings.SoundsBackground + "music_level_2.mp3", true, true);
MusicChannel = Music.Play();
AddChild(Pause);
}
示例4: MainMenu
public MainMenu(TimeGuardianGame game)
{
_game = game;
SetBackground();
SetHeader();
_buttons = new []
{
new Button(UtilStrings.SpritesMenu + "button_newgame.png", 2, game.width/2, 350, "Level1"),
new Button(UtilStrings.SpritesMenu + "button_highscore.png", 2, game.width/2, 450, "HighScores"),
new Button(UtilStrings.SpritesMenu + "button_credits.png", 2, game.width/2, 550, "Credits"),
new Button(UtilStrings.SpritesMenu + "button_exit.png", 2, game.width/2, 650, "Exit")
};
foreach (Button button in _buttons)
{
AddChild(button);
}
_selectedSound = new Sound(UtilStrings.SoundsMenu + "sound_selected.wav");
_music = new Sound(UtilStrings.SoundsMenu + "music_menu.mp3", true, true);
_musicChannel = _music.Play();
_buttons[0].Selected();
}
示例5: lnkPlay_Click
private void lnkPlay_Click(object sender, EventArgs e)
{
SoundInfo selectedSound = (SoundInfo)cmbSound.SelectedItem;
s = new Sound(selectedSound.Path);
s.Play();
}
示例6: PlaySound
/** <summary> Plays the specified sound effect. </summary> */
public static SoundInstance PlaySound(Sound sound, bool looped, float volume = 1.0f, float pitch = 0.0f, float pan = 0.0f, bool muted = false)
{
return sound.Play(looped, volume, pitch, pan, muted);
}
示例7: NewItems
//This gets called every time a fetch finds new items.
public void NewItems()
{
foreach (var infoClass in _notifications.Values)
{
if(TimeLines.LastSelectedItems.GetUnreadItems(infoClass.ListName)>0)
{
string constraints ="";
if (infoClass.Group != null) { constraints = infoClass.Group.GetConstraints(); }
if (infoClass.LastSeenID != LocalStorage.DataBaseUtility.GetNewestItem(infoClass.Type, constraints))
{
if ((infoClass.Options & Options.Vibrate) == Options.Vibrate && SoundProfileCheck.VibrateOn())
{
VibrateStart();
try
{
if ((infoClass.Options & Options.Sound) == Options.Sound)
{
var s = new Sound(infoClass.Sound);
s.Play();
}
else
{
System.Threading.Thread.Sleep(1000);
}
}
finally
{
// always turn it off
// I've woken up to find the blasted phone buzzing
VibrateStop();
}
}
else if ((infoClass.Options & Options.Sound) == Options.Sound && SoundProfileCheck.VolumeOn())
{
var s = new Sound(infoClass.Sound);
s.Play();
}
if ((infoClass.Options & Options.Message) == Options.Message)
{
ShowNotifications();
}
infoClass.LastSeenID = LocalStorage.DataBaseUtility.GetNewestItem(infoClass.Type, constraints);
}
}
}
}
示例8: loopMusic
private void loopMusic()
{
if (_loopStarted) return;
if (soundChannel.IsPlaying == false)
{
soundChannel.Volume = 0.001f;
Sound backgroundloop = new Sound("backgroundloop.mp3", true, true);
backgroundloop.Play(false, 1);
_loopStarted = true;
}
}
示例9: playSound
//воспроизвести выбранную музыку
int playSound(string nameSound)
{
// Sound soundMusic = new Sound(nameSound + ".wav");
Sound soundMusic = new Sound(nameSound + ".wav");
soundMusic.Play();
return 0;
}