Calculate length if unknown.

This commit is contained in:
2015-11-01 14:24:16 +01:00
parent 93f9879c14
commit d774e250c5
+7 -2
View File
@@ -121,6 +121,7 @@ namespace MusicPlayer
}
catch(Exception e)
{
Console.WriteLine(e.StackTrace);
AState = AudioState.STOPPED;
main.form.SongFinished();
return;
@@ -135,7 +136,10 @@ namespace MusicPlayer
waveOut.Init(blockAlignedStream);
waveOut.Play();
Length = CurrentSong.Seconds * waveOut.OutputWaveFormat.AverageBytesPerSecond;
if (CurrentSong.Seconds == 0)
Length = ms.Length / waveOut.OutputWaveFormat.AverageBytesPerSecond;
else
Length = CurrentSong.Seconds * waveOut.OutputWaveFormat.AverageBytesPerSecond;
CurrentTime = (int)(ms.Position / waveOut.OutputWaveFormat.AverageBytesPerSecond);
while (waveOut.PlaybackState != PlaybackState.Stopped)
@@ -175,7 +179,7 @@ namespace MusicPlayer
}
if(AState == AudioState.PLAYING)
if(AState == AudioState.PLAYING && !firstrun)
main.form.SongFinished();
AState = AudioState.STOPPED;
playpos = 0;
@@ -206,6 +210,7 @@ namespace MusicPlayer
}
catch(Exception e)
{
Console.WriteLine(e.StackTrace);
BState = BufferState.EMPTY;
AState = AudioState.STOPPED;
main.form.SongFinished();