OpenBve.SoundManager.IsPlaying C# (CSharp) Méthode

IsPlaying() static private méthode

static private IsPlaying ( int SoundSourceIndex ) : bool
SoundSourceIndex int
Résultat bool
		internal static bool IsPlaying(int SoundSourceIndex) {
			if (OpenAlContext != ContextHandle.Zero) {
				if (SoundSourceIndex >= 0 && SoundSourceIndex < SoundSources.Length && SoundSources[SoundSourceIndex] != null) {
					if (SoundSources[SoundSourceIndex].Suppressed) {
						return true;
					} else {
						if (SoundSources[SoundSourceIndex].OpenAlSourceIndex.Valid) {
							int i = SoundSources[SoundSourceIndex].OpenAlSourceIndex.Index;
							int state;
							AL.GetSource(i, ALGetSourcei.SourceState, out state);
							return state == (int)ALSourceState.Playing;
						} else {
							return false;
						}
					}
				} else {
					return false;
				}
			} else {
				return false;
			}
		}

Usage Example

Exemple #1
0
        internal override void Elapse(ElapseData data)
        {
            try
            {
                this.Api.Elapse(data);

                /*
                 * Process the sounds.
                 * */
                for (int i = 0; i < this.SoundCount; i++)
                {
                    if (this.Sounds[i].Playing || !SoundManager.IsPlaying(this.Sounds[i].SoundSourceIndex))
                    {
                        SoundManager.StopSound(ref this.Sounds[i].SoundSourceIndex);
                        this.Sounds[i].Stop();
                        this.Sounds[i] = this.Sounds[this.SoundCount - 1];
                        this.SoundCount--;
                        i--;
                    }
                    else
                    {
                        double pitch  = Math.Max(0.01, this.Sounds[i].Pitch);
                        double volume = Math.Max(0.0, this.Sounds[i].Volume);
                        SoundManager.ModulateSound(this.Sounds[i].SoundSourceIndex, pitch, volume);
                    }
                }
            }
            catch (Exception ex)
            {
                base.LastException = ex;
                throw;
            }
        }
All Usage Examples Of OpenBve.SoundManager::IsPlaying