OpenBve.Sounds.StopSound C# (CSharp) Method

StopSound() static private method

Stops the specified sound source.
static private StopSound ( SoundSource source ) : void
source SoundSource The sound source, or a null reference.
return void
		internal static void StopSound(SoundSource source) {
			if (source != null) {
				if (source.State == SoundSourceState.Playing) {
					AL.DeleteSources(1, ref source.OpenAlSourceName);
					source.OpenAlSourceName = 0;
				}
				source.State = SoundSourceState.Stopped;
			}
		}
		

Usage Example

Beispiel #1
0
 /// <summary>Called by the controls loop to stop playback of this horn</summary>
 internal void Stop()
 {
     //Reset loop control variable
     LoopStarted = false;
     if (!StartEndSounds & !Loop)
     {
         //Don't stop horns which are play-once single part sounds
         return;
     }
     if (!StartEndSounds & Loop)
     {
         //This sound is a toggle music horn sound
         return;
     }
     if (Sounds.IsPlaying(Source))
     {
         //Stop the loop sound playing
         Sounds.StopSound(Source);
     }
     if (StartEndSounds && !Sounds.IsPlaying(Source) && EndSound != null)
     {
         //If our end sound is defined and in use, play once
         Source = Sounds.PlaySound(EndSound, 1.0, 1.0, SoundPosition,
                                   TrainManager.PlayerTrain,
                                   TrainManager.PlayerTrain.DriverCar, false);
     }
 }
All Usage Examples Of OpenBve.Sounds::StopSound