Stop video soundtrack when video stops

This commit is contained in:
Paul Chote
2010-08-12 00:44:53 +12:00
parent 6e0158039a
commit 74500c369c
2 changed files with 12 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ namespace OpenRA
static ISoundEngine soundEngine; static ISoundEngine soundEngine;
static Cache<string, ISoundSource> sounds; static Cache<string, ISoundSource> sounds;
static ISound music; static ISound music;
static ISound video;
static bool paused; static bool paused;
static bool stopped; static bool stopped;
@@ -42,6 +43,7 @@ namespace OpenRA
soundEngine = new OpenAlSoundEngine(); soundEngine = new OpenAlSoundEngine();
sounds = new Cache<string, ISoundSource>(LoadSound); sounds = new Cache<string, ISoundSource>(LoadSound);
music = null; music = null;
video = null;
paused = false; paused = false;
stopped = false; stopped = false;
} }
@@ -49,10 +51,16 @@ namespace OpenRA
public static void SetListenerPosition(float2 position) { soundEngine.SetListenerPosition(position); } public static void SetListenerPosition(float2 position) { soundEngine.SetListenerPosition(position); }
static ISoundSource rawSource; static ISoundSource rawSource;
public static void PlayRaw(byte[] raw) public static void PlayVideoSoundtrack(byte[] raw)
{ {
rawSource = LoadSoundRaw(raw); rawSource = LoadSoundRaw(raw);
soundEngine.Play2D(rawSource, false, true, float2.Zero, SoundVolume); video = soundEngine.Play2D(rawSource, false, true, float2.Zero, SoundVolume);
}
public static void StopVideoSoundtrack()
{
if (video != null)
soundEngine.StopSound(video);
} }
public static void Play(string name) public static void Play(string name)

View File

@@ -68,13 +68,13 @@ namespace OpenRA.Widgets
video.Reset(); video.Reset();
videoSprite.sheet.Texture.SetData(video.FrameData); videoSprite.sheet.Texture.SetData(video.FrameData);
sw.Reset(); sw.Reset();
Sound.PlayRaw(video.AudioData); Sound.PlayVideoSoundtrack(video.AudioData);
} }
public void Stop() public void Stop()
{ {
playing = false; playing = false;
// TODO: Stop audio Sound.StopVideoSoundtrack();
} }
} }
} }