本文整理汇总了C#中SoundState类的典型用法代码示例。如果您正苦于以下问题:C# SoundState类的具体用法?C# SoundState怎么用?C# SoundState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SoundState类属于命名空间,在下文中一共展示了SoundState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleSoundBufferRecycled
/// <summary>
/// Event handler that resets internal state of this instance. The sound state will report
/// SoundState.Stopped after this event handler.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HandleSoundBufferRecycled(object sender, EventArgs e)
{
sourceId = 0;
hasSourceId = false;
soundState = SoundState.Stopped;
//Console.WriteLine ("recycled: " + soundEffect.Name);
}
示例2: PlatformPlay
private void PlatformPlay()
{
if (_soundPlayer != null)
_soundPlayer.Play();
soundState = SoundState.Playing;
}
示例3: PlatformPause
private void PlatformPause()
{
if (_soundPlayer != null)
_soundPlayer.Stop();
soundState = SoundState.Paused;
}
示例4: PlatformPause
private void PlatformPause()
{
if (streamId == 0)
return;
s_soundPool.Pause(streamId);
soundState = SoundState.Paused;
}
示例5: Pause
public void Pause ()
{
if ( _sound != null )
{
_sound.Pause();
soundState = SoundState.Paused;
}
}
示例6: PlatformStop
private void PlatformStop(bool immediate)
{
if (_soundPlayer != null )
{
_soundPlayer.Stop();
}
soundState = SoundState.Stopped;
}
示例7: Play
public void Play()
{
if (soundEffect != null)
{
soundEffect.Play();
SoundState previousStateTemp = previousState;
previousState = SoundState.Playing;
if (SoundStateChanged != null)
SoundStateChanged.Invoke(previousStateTemp, previousState);
}
}
示例8: Load
public void Load()
{
if (Status == SoundState.Unloaded)
{
Status = SoundState.Loading;
// I commented out this code because we let windows handle loading mp3s.
// Static song ctor requires a URI, which is a pain in the butt,
// so we're going to just reflect out the ctor.
/*var ctor = typeof(Song).GetConstructor(
BindingFlags.NonPublic | BindingFlags.Instance, null,
new[] { typeof(string), typeof(string), typeof(int) }, null);*/
// m_Song = (Song)ctor.Invoke(new object[] { Name, Path, 0 });
Status = SoundState.Loaded;
}
}
示例9: PlatformDispose
private void PlatformDispose(bool disposing)
{
if (disposing)
{
if (_soundPlayer != null)
{
_soundPlayer.Stop();
_soundPlayer.Dispose();
}
if (_audioBuffer != null)
_audioBuffer.Dispose();
}
_soundPlayer = null;
_audioBuffer = null;
soundState = SoundState.Stopped;
}
示例10: ChangState
public void ChangState()
{
if (Count % 2 == 0)
{
currentSoundState = SoundState.OFF;
mutte.SetActive(true);
Count++;
StopGameAudio();
}
else
{
currentSoundState = SoundState.ON;
mutte.SetActive(false);
Count++;
PlayMenuAudio();
}
}
示例11: SetSound
public void SetSound(Sound sound)
{
if (soundEffect != null)
soundEffect.Stop();
previousState = SoundState.Stopped;
string path = CatrobatContext.Instance.CurrentProject.BasePath + "/" + Project.SoundsPath + "/" + sound.FileName;
using (IStorage storage = StorageSystem.GetStorage())
{
if (storage.FileExists(path))
using (Stream stream = storage.OpenFile(path, StorageFileMode.Open, StorageFileAccess.Read))
{
byte[] soundArray = new byte[stream.Length];
stream.Read(soundArray, 0, soundArray.Length);
stream.Close();
soundEffect = new SoundEffect(soundArray, Microphone.Default.SampleRate, AudioChannels.Mono).CreateInstance();
}
}
checkSoundThread = new System.Threading.Thread(checkIfSoundFinished);
}
示例12: Play
public void Play ()
{
#if WINRT
if (_voice != null)
{
// Choose the correct buffer depending on if we are looped.
var buffer = _loop ? _effect._loopedBuffer : _effect._buffer;
if (_voice.State.BuffersQueued > 0)
{
_voice.Stop();
_voice.FlushSourceBuffers();
}
_voice.SubmitSourceBuffer(buffer, null);
_voice.Start();
}
_paused = false;
#else
if ( _sound != null )
{
#if ANDROID
if (soundState == SoundState.Paused)
_sound.Resume(_streamId);
else
_streamId = _sound.Play();
#else
if (soundState == SoundState.Paused)
_sound.Resume();
else
_sound.Play();
#endif
soundState = SoundState.Playing;
}
#endif
}
示例13: Resume
public void Resume()
{
#if WINRT
if (_voice != null)
{
// Restart the sound if (and only if) it stopped playing
if (!_loop)
{
if (_voice.State.BuffersQueued == 0)
{
_voice.Stop();
_voice.FlushSourceBuffers();
_voice.SubmitSourceBuffer(_effect._buffer, null);
}
}
_voice.Start();
}
_paused = false;
#else
if ( _sound != null )
{
if (soundState == SoundState.Paused)
{
#if ANDROID
_sound.Resume(_streamId);
#else
_sound.Resume();
#endif
}
soundState = SoundState.Playing;
}
#endif
}
示例14: Pause
public void Pause ()
{
#if WINRT
if (_voice != null)
_voice.Stop();
_paused = true;
#else
if ( _sound != null )
{
#if ANDROID
_sound.Pause(_streamId);
#else
_sound.Pause();
#endif
soundState = SoundState.Paused;
}
#endif
}
示例15: Update
//Update all of the elements that need updating in the Controller Detect Screen
public override void Update(GameTime theTime)
{
MouseState mouse = Mouse.GetState();
Rectangle hoverPosition = new Rectangle(mouse.X, mouse.Y, 1, 1);
if (hoverPosition.Intersects(btnKembaliPosition))
{
btnKembali = btnKembaliHover;
}
else
{
btnKembali = btnKembaliActive;
}
if (mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
{
Point pointer = new Point(mouse.X, mouse.Y);
if (btnKembaliPosition.Contains(pointer))
{
Game1.MOUSE_DOWN.Play();
Thread.Sleep(200);
if (PlayScreen.SUB_LEVEL == Game1.LEVEL11 || PlayScreen.SUB_LEVEL == Game1.LEVEL12)
{
ScreenEvent.Invoke(Game1.LEVEL1, new EventArgs());
return;
}
else if (PlayScreen.SUB_LEVEL == Game1.LEVEL21 || PlayScreen.SUB_LEVEL == Game1.LEVEL22)
{
ScreenEvent.Invoke(Game1.LEVEL2, new EventArgs());
return;
}
else
{
ScreenEvent.Invoke(Game1.LEVEL_SCREEN, new EventArgs());
return;
}
}
soundState = soundInstance.State;
if (btnSoal1Position.Contains(pointer))
{
if (currentSound == 1 && soundState == SoundState.Playing)
{
soundInstance.Stop();
btnSoal1 = btnPlay;
}
else
{
soundInstance.Stop();
soundInstance = soundSoal[0].CreateInstance();
btnSoal1 = btnStop;
soundInstance.Play();
soundState = soundInstance.State;
currentSound = 1;
btnSoal2 = btnPlay;
btnSoal3 = btnPlay;
btnSoal4 = btnPlay;
btnSoal5 = btnPlay;
}
}
else if (btnSoal2Position.Contains(pointer))
{
if (currentSound == 2 && soundState == SoundState.Playing)
{
soundInstance.Stop();
btnSoal2 = btnPlay;
}
else
{
soundInstance.Stop();
soundInstance = soundSoal[1].CreateInstance();
btnSoal2 = btnStop;
soundInstance.Play();
soundState = soundInstance.State;
currentSound = 2;
btnSoal1 = btnPlay;
btnSoal3 = btnPlay;
btnSoal4 = btnPlay;
btnSoal5 = btnPlay;
}
}
else if (btnSoal3Position.Contains(pointer))
{if (currentSound == 3 && soundState == SoundState.Playing)
{
soundInstance.Stop();
btnSoal3 = btnPlay;
}
else
{
soundInstance.Stop();
soundInstance = soundSoal[2].CreateInstance();
btnSoal3 = btnStop;
soundInstance.Play();
soundState = soundInstance.State;
currentSound = 3;
btnSoal1 = btnPlay;
//.........这里部分代码省略.........