(gecko) Return the ISound when playing sounds, so you can stop it later

This commit is contained in:
Chris Forbes
2010-11-02 13:41:51 +13:00
parent 6655b6ba6a
commit 5e3fce6820

View File

@@ -48,34 +48,46 @@ namespace OpenRA
public static void SetListenerPosition(float2 position) { soundEngine.SetListenerPosition(position); }
public static void Play(string name)
public static ISound Play(string name)
{
return Play(name, float2.Zero);
}
public static ISound Play(string name, float2 pos)
{
if (name == "" || name == null)
return;
return null;
var sound = sounds[name];
soundEngine.Play2D(sound, false, true, float2.Zero, InternalSoundVolume);
return soundEngine.Play2D(sound, false, false, pos, InternalSoundVolume);
}
public static void Play(string name, float2 pos)
public static ISound Play(string name, float volumeModifier)
{
return Play(name, float2.Zero, volumeModifier);
}
public static ISound Play(string name, float2 pos, float volumeModifier)
{
if (name == "" || name == null)
return;
return null;
var sound = sounds[name];
soundEngine.Play2D(sound, false, false, pos, InternalSoundVolume);
return soundEngine.Play2D(sound, false, false, pos, InternalSoundVolume * volumeModifier);
}
public static void PlayToPlayer(Player player, string name)
public static ISound PlayToPlayer(Player player, string name)
{
if( player == player.World.LocalPlayer )
Play( name );
return PlayToPlayer(player, name, float2.Zero);
}
public static void PlayToPlayer(Player player, string name, float2 pos)
public static ISound PlayToPlayer(Player player, string name, float2 pos)
{
if (player == player.World.LocalPlayer)
Play(name, pos);
return Play(name, pos);
return null;
}
public static void PlayVideo(byte[] raw)
@@ -147,6 +159,12 @@ namespace OpenRA
soundEngine.PauseSound(music, false);
}
public static void StopSound(ISound sound)
{
if (sound != null)
soundEngine.StopSound(sound);
}
public static void StopMusic()
{
if (music != null)
@@ -262,7 +280,8 @@ namespace OpenRA
}
interface ISoundSource { }
interface ISound
public interface ISound
{
float Volume { get; set; }
float SeekPosition { get; }