Better handling of radiostation

This commit is contained in:
2015-11-01 19:51:43 +01:00
parent 90f35de242
commit 98f6ab9bc0
+19 -7
View File
@@ -17,7 +17,13 @@ namespace MusicPlayer
public AudioState AState { get; set; } public AudioState AState { get; set; }
public BufferState BState { get; set; } public BufferState BState { get; set; }
public int Buffered { get { return Math.Min((int)((bufpos / (double)LengthBuffer) * 1000), 1000); } } public int Buffered { get
{
if(CurrentSong is RadioStation)
return Math.Min((int)((bufpos - ms.Position) / 1000), 1000);
else
return Math.Min((int)((bufpos / (double)LengthBuffer) * 1000), 1000);
} }
private long LengthBuffer { get; set; } private long LengthBuffer { get; set; }
private long bufpos = 0; private long bufpos = 0;
@@ -33,7 +39,7 @@ namespace MusicPlayer
private long seek = 0; private long seek = 0;
private Stream ms; private MemoryStream ms;
private Thread network; private Thread network;
private Thread audio; private Thread audio;
@@ -168,10 +174,17 @@ namespace MusicPlayer
} }
if (BState == BufferState.DONE && firstrun ) if (BState == BufferState.DONE && firstrun )
{ {
position = mp3fr.Position; if( ! (CurrentSong is RadioStation))
mp3fr.Close(); {
StreamFromMP3(ms,position, false); position = mp3fr.Position;
break; mp3fr.Close();
StreamFromMP3(ms, position, false);
break;
}
else
{
AState = AudioState.STOPPED;
}
} }
playpos = blockAlignedStream.Position; playpos = blockAlignedStream.Position;
@@ -242,7 +255,6 @@ namespace MusicPlayer
ms.Write(buffer, 0, read); ms.Write(buffer, 0, read);
ms.Position = pos; ms.Position = pos;
this.bufpos = ms.Length; this.bufpos = ms.Length;
} }
} }