Stop video soundtrack when video stops
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user