Fix PlaySound (Length not gotten if prescan off)

Add fade option to PlaySound
This commit is contained in:
Flamefire committed 2014-03-14 00:27:42 +01:00
1 parent 45e480785d
commit 88364ce64b
1 file changed
+6 -3
+6 -3
View File
@@ -181,7 +181,7 @@ namespace Vocaluxe.Base
#endregion Playback #endregion Playback
#region Sounds #region Sounds
public static int PlaySound(ESounds sound) public static int PlaySound(ESounds sound, bool fade = true)
{ {
string file = Path.Combine(Environment.CurrentDirectory, CSettings.FolderSounds); string file = Path.Combine(Environment.CurrentDirectory, CSettings.FolderSounds);
switch (sound) switch (sound)
@@ -189,14 +189,17 @@ namespace Vocaluxe.Base
case ESounds.T440: case ESounds.T440:
file = Path.Combine(file, CSettings.SoundT440); file = Path.Combine(file, CSettings.SoundT440);
break; break;
default:
return -1;
} }
if (file == "") if (!File.Exists(file))
return -1; return -1;
int stream = Load(file); int stream = Load(file, true);
float length = GetLength(stream); float length = GetLength(stream);
Play(stream); Play(stream);
if (fade)
FadeAndClose(stream, 100f, length); FadeAndClose(stream, 100f, length);
return stream; return stream;
} }