Sound NumberOfPlayingInstances Property Delta Engine Documentation

Namespace: DeltaEngine.Multimedia
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public int NumberOfPlayingInstances { get; }

Property Value

Type: Int32
Remarks

Tests: DeltaEngine.Multimedia.Tests.SoundTests
Examples

3 unit tests call DeltaEngine.Multimedia.Sound.NumberOfPlayingInstances
[Test]
public void NumberOfPlayingInstances()
{
    var sound = ContentLoader.Load<Sound>("DefaultSound");
    Assert.AreEqual(0, sound.NumberOfPlayingInstances);
    sound.Play();
    Assert.AreEqual(1, sound.NumberOfPlayingInstances);
    sound.Play();
    Assert.AreEqual(2, sound.NumberOfPlayingInstances);
}
[Test]
public void DisposeSoundInstance()
{
    var sound = ContentLoader.Load<Sound>("DefaultSound");
    var instance = sound.CreateSoundInstance();
    Assert.AreEqual(1, sound.NumberOfInstances);
    Assert.AreEqual(0, sound.NumberOfPlayingInstances);
    instance.Dispose();
    Assert.AreEqual(0, sound.NumberOfInstances);
    Assert.AreEqual(0, sound.NumberOfPlayingInstances);
}
[Test]
public void DisposeSoundInstancesFromSoundClass()
{
    var sound = ContentLoader.Load<Sound>("DefaultSound");
    sound.CreateSoundInstance();
    sound.Play();
    Assert.AreEqual(2, sound.NumberOfInstances);
    Assert.AreEqual(1, sound.NumberOfPlayingInstances);
    sound.Dispose();
    Assert.AreEqual(0, sound.NumberOfInstances);
    Assert.AreEqual(0, sound.NumberOfPlayingInstances);
}
See Also