Fixed pause

This commit is contained in:
Kwoth 2016-12-22 08:12:51 +01:00
parent 58f2540083
commit 34a9a3dd5f
2 changed files with 23 additions and 14 deletions

View File

@ -170,10 +170,15 @@ namespace NadekoBot.Modules.Music.Classes
if (slowconnection) if (slowconnection)
{ {
_log.Warn("Slow connection has disrupted music, waiting a bit for buffer"); _log.Warn("Slow connection has disrupted music, waiting a bit for buffer");
await Task.Delay(1000, cancelToken).ConfigureAwait(false); await Task.Delay(1000, cancelToken).ConfigureAwait(false);
nextTime = Environment.TickCount + milliseconds;
} }
else else
{
await Task.Delay(100, cancelToken).ConfigureAwait(false); await Task.Delay(100, cancelToken).ConfigureAwait(false);
nextTime = Environment.TickCount + milliseconds;
}
} }
else else
attempt = 0; attempt = 0;
@ -182,7 +187,10 @@ namespace NadekoBot.Modules.Music.Classes
attempt = 0; attempt = 0;
while (this.MusicPlayer.Paused) while (this.MusicPlayer.Paused)
{
await Task.Delay(200, cancelToken).ConfigureAwait(false); await Task.Delay(200, cancelToken).ConfigureAwait(false);
nextTime = Environment.TickCount + milliseconds;
}
buffer = AdjustVolume(buffer, MusicPlayer.Volume); buffer = AdjustVolume(buffer, MusicPlayer.Volume);

View File

@ -25,15 +25,15 @@ namespace NadekoBot.Modules.Music.Classes
_log = LogManager.GetCurrentClassLogger(); _log = LogManager.GetCurrentClassLogger();
} }
MusicPlayer MusicPlayer; MusicPlayer MusicPlayer { get; }
private string Basename; private string Basename { get; }
private SongInfo SongInfo; private SongInfo SongInfo { get; }
private int SkipTo; private int SkipTo { get; }
private int MaxFileSize = 2.MiB(); private int MaxFileSize { get; } = 2.MiB();
private long FileNumber = -1; private long FileNumber = -1;
@ -76,7 +76,8 @@ namespace NadekoBot.Modules.Music.Classes
try try
{ {
outStream.Dispose(); outStream.Dispose();
}catch { } }
catch { }
outStream = new FileStream(Basename + "-" + ++FileNumber, FileMode.Append, FileAccess.Write, FileShare.Read); outStream = new FileStream(Basename + "-" + ++FileNumber, FileMode.Append, FileAccess.Write, FileShare.Read);
currentFileSize = bytesRead; currentFileSize = bytesRead;
} }