Skip to content

Commit

Permalink
MusicPlayer.Seek does not throw ArgumentOutOfRangeException
Browse files Browse the repository at this point in the history
  • Loading branch information
geloczi committed Jan 9, 2022
1 parent 7e058e9 commit e32d3d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions SynAudio/MediaPlayer/MusicPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class MusicPlayer : ViewModelBase, IDisposable
private bool _disposed;
private BackgroundThreadWorker _streamWorker;
private BackgroundAsyncTaskWorker _pollTask;
private BackgroundAsyncTaskWorker _pauseCleanupWorker;
private SongModel _song;
private BlockingReadStream _songStream;
private long _songStreamFullLength;
Expand Down Expand Up @@ -109,8 +110,6 @@ public void Play()
}
}

BackgroundAsyncTaskWorker _pauseCleanupWorker;

public void Pause()
{
lock (_lock)
Expand Down Expand Up @@ -282,10 +281,12 @@ private void Seek(TimeSpan position)
lock (_lock)
{
StopPolling();

if (_song is null)
return;
if (position >= Length)
throw new ArgumentOutOfRangeException(nameof(position));

if (position > Length - TimeSpan.FromSeconds(1))
position = Length > TimeSpan.FromSeconds(1) ? Length - TimeSpan.FromSeconds(1) : TimeSpan.Zero;

if (PlaybackState == PlaybackStateType.Playing)
{
Expand Down Expand Up @@ -353,7 +354,7 @@ private void StopPolling()
}
}

public void UpdateCounters()
private void UpdateCounters()
{
lock (_lock)
{
Expand Down
2 changes: 1 addition & 1 deletion SynAudio/SynAudio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- General -->
<PropertyGroup>
<Product>SynAudio</Product>
<Version>0.6.1</Version>
<Version>0.6.2</Version>
<Description>Stream music from your Synology NAS.</Description>
<RepositoryUrl>https://github.com/geloczigeri/synologydotnet-audiostation-wpf</RepositoryUrl>
<Authors>Gergő Gelóczi</Authors>
Expand Down

0 comments on commit e32d3d1

Please sign in to comment.