Fixed pause
This commit is contained in:
parent
58f2540083
commit
34a9a3dd5f
@ -170,10 +170,15 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
if (slowconnection)
|
||||
{
|
||||
_log.Warn("Slow connection has disrupted music, waiting a bit for buffer");
|
||||
|
||||
await Task.Delay(1000, cancelToken).ConfigureAwait(false);
|
||||
nextTime = Environment.TickCount + milliseconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Delay(100, cancelToken).ConfigureAwait(false);
|
||||
nextTime = Environment.TickCount + milliseconds;
|
||||
}
|
||||
}
|
||||
else
|
||||
attempt = 0;
|
||||
@ -182,7 +187,10 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
attempt = 0;
|
||||
|
||||
while (this.MusicPlayer.Paused)
|
||||
{
|
||||
await Task.Delay(200, cancelToken).ConfigureAwait(false);
|
||||
nextTime = Environment.TickCount + milliseconds;
|
||||
}
|
||||
|
||||
|
||||
buffer = AdjustVolume(buffer, MusicPlayer.Volume);
|
||||
|
@ -25,21 +25,21 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
_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 NextFileToRead = 0;
|
||||
|
||||
public bool BufferingCompleted { get; private set;} = false;
|
||||
public bool BufferingCompleted { get; private set; } = false;
|
||||
|
||||
private ulong CurrentBufferSize = 0;
|
||||
|
||||
@ -76,7 +76,8 @@ namespace NadekoBot.Modules.Music.Classes
|
||||
try
|
||||
{
|
||||
outStream.Dispose();
|
||||
}catch { }
|
||||
}
|
||||
catch { }
|
||||
outStream = new FileStream(Basename + "-" + ++FileNumber, FileMode.Append, FileAccess.Write, FileShare.Read);
|
||||
currentFileSize = bytesRead;
|
||||
}
|
||||
@ -108,8 +109,8 @@ Check the guides for your platform on how to setup ffmpeg correctly:
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(outStream != null)
|
||||
outStream.Dispose();
|
||||
if (outStream != null)
|
||||
outStream.Dispose();
|
||||
Console.WriteLine($"Buffering done.");
|
||||
if (p != null)
|
||||
{
|
||||
@ -130,7 +131,7 @@ Check the guides for your platform on how to setup ffmpeg correctly:
|
||||
private string GetNextFile()
|
||||
{
|
||||
string filename = Basename + "-" + NextFileToRead;
|
||||
|
||||
|
||||
if (NextFileToRead != 0)
|
||||
{
|
||||
try
|
||||
@ -151,7 +152,7 @@ Check the guides for your platform on how to setup ffmpeg correctly:
|
||||
|
||||
private void CleanFiles()
|
||||
{
|
||||
for (long i = NextFileToRead - 1 ; i <= FileNumber; i++)
|
||||
for (long i = NextFileToRead - 1; i <= FileNumber; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -169,7 +170,7 @@ Check the guides for your platform on how to setup ffmpeg correctly:
|
||||
|
||||
public override bool CanWrite => false;
|
||||
|
||||
public override long Length => (long) CurrentBufferSize;
|
||||
public override long Length => (long)CurrentBufferSize;
|
||||
|
||||
public override long Position { get; set; } = 0;
|
||||
|
||||
@ -178,7 +179,7 @@ Check the guides for your platform on how to setup ffmpeg correctly:
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
int read = CurrentFileStream.Read(buffer, offset, count);
|
||||
if(read < count)
|
||||
if (read < count)
|
||||
{
|
||||
if (!BufferingCompleted || IsNextFileReady())
|
||||
{
|
||||
@ -215,4 +216,4 @@ Check the guides for your platform on how to setup ffmpeg correctly:
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user