Selecting "Next Index" on a track may cause an exception #3

Closed
opened 2026-01-30 21:22:46 +00:00 by claunia · 1 comment
Owner

Originally created by @mnadareski on GitHub (Jun 5, 2021).

Originally assigned to: @mnadareski on GitHub.

Without the "Index navigation can change track" setting enabled, if you click "Next Index" on a track where you are on the last index of the track, it will throw an exception:

System.Collections.Generic.KeyNotFoundException
  HResult=0x80131577
  Message=The given key '2' was not present in the dictionary.
  Source=System.Private.CoreLib
  StackTrace:
   at System.ThrowHelper.ThrowKeyNotFoundException[T](T key)
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at RedBookPlayer.Player.set_CurrentIndex(UInt16 value) in B:\Programs\GitHub\RedBookPlayer\RedBookPlayer\Player.cs:line 86
   at RedBookPlayer.Player.NextIndex(Boolean changeTrack) in B:\Programs\GitHub\RedBookPlayer\RedBookPlayer\Player.cs:line 433
   at RedBookPlayer.PlayerView.NextIndexButton_Click(Object sender, RoutedEventArgs e) in B:\Programs\GitHub\RedBookPlayer\RedBookPlayer\PlayerView.xaml.cs:line 107
   at Avalonia.Interactivity.Interactive.RaiseEventImpl(RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.HierarchyTraverser`2.Traverse(IInteractive target)
   at Avalonia.Interactivity.Interactive.BubbleEvent(RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
   at Avalonia.Controls.Button.OnClick()
   at Avalonia.Controls.Button.OnPointerReleased(PointerReleasedEventArgs e)
   at System.Reactive.AnonymousObserver`1.OnNextCore(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\AnonymousObserver.cs:line 67
   at System.Reactive.ObserverBase`1.OnNext(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\ObserverBase.cs:line 36
   at System.Reactive.Subjects.Subject`1.OnNext(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Subjects\Subject.cs:line 148
   at Avalonia.Interactivity.Interactive.RaiseEventImpl(RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.HierarchyTraverser`2.Traverse(IInteractive target)
   at Avalonia.Interactivity.Interactive.HierarchyTraverser`2.Traverse(IInteractive target)
   at Avalonia.Interactivity.Interactive.BubbleEvent(RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
   at Avalonia.Input.MouseDevice.MouseUp(IMouseDevice device, UInt64 timestamp, IInputRoot root, Point p, PointerPointProperties props, KeyModifiers inputModifiers)
   at Avalonia.Input.MouseDevice.ProcessRawEvent(RawPointerEventArgs e)
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e)
   at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode)
   at RedBookPlayer.Program.Main(String[] args) in B:\Programs\GitHub\RedBookPlayer\RedBookPlayer\Program.cs:line 14

For example, the above was generated when playing a track with only indices 0 and 1, playing index 1, and then attempting to hit "Next Index". The fix for this is to enable earlier boundary checking. If the setting mentioned above is enabled, this should go to the next track, otherwise, the button should do nothing.

Originally created by @mnadareski on GitHub (Jun 5, 2021). Originally assigned to: @mnadareski on GitHub. Without the "Index navigation can change track" setting enabled, if you click "Next Index" on a track where you are on the last index of the track, it will throw an exception: ``` System.Collections.Generic.KeyNotFoundException HResult=0x80131577 Message=The given key '2' was not present in the dictionary. Source=System.Private.CoreLib StackTrace: at System.ThrowHelper.ThrowKeyNotFoundException[T](T key) at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at RedBookPlayer.Player.set_CurrentIndex(UInt16 value) in B:\Programs\GitHub\RedBookPlayer\RedBookPlayer\Player.cs:line 86 at RedBookPlayer.Player.NextIndex(Boolean changeTrack) in B:\Programs\GitHub\RedBookPlayer\RedBookPlayer\Player.cs:line 433 at RedBookPlayer.PlayerView.NextIndexButton_Click(Object sender, RoutedEventArgs e) in B:\Programs\GitHub\RedBookPlayer\RedBookPlayer\PlayerView.xaml.cs:line 107 at Avalonia.Interactivity.Interactive.RaiseEventImpl(RoutedEventArgs e) at Avalonia.Interactivity.Interactive.HierarchyTraverser`2.Traverse(IInteractive target) at Avalonia.Interactivity.Interactive.BubbleEvent(RoutedEventArgs e) at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) at Avalonia.Controls.Button.OnClick() at Avalonia.Controls.Button.OnPointerReleased(PointerReleasedEventArgs e) at System.Reactive.AnonymousObserver`1.OnNextCore(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\AnonymousObserver.cs:line 67 at System.Reactive.ObserverBase`1.OnNext(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\ObserverBase.cs:line 36 at System.Reactive.Subjects.Subject`1.OnNext(T value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Subjects\Subject.cs:line 148 at Avalonia.Interactivity.Interactive.RaiseEventImpl(RoutedEventArgs e) at Avalonia.Interactivity.Interactive.HierarchyTraverser`2.Traverse(IInteractive target) at Avalonia.Interactivity.Interactive.HierarchyTraverser`2.Traverse(IInteractive target) at Avalonia.Interactivity.Interactive.BubbleEvent(RoutedEventArgs e) at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e) at Avalonia.Input.MouseDevice.MouseUp(IMouseDevice device, UInt64 timestamp, IInputRoot root, Point p, PointerPointProperties props, KeyModifiers inputModifiers) at Avalonia.Input.MouseDevice.ProcessRawEvent(RawPointerEventArgs e) at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e) at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg) at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken) at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) at RedBookPlayer.Program.Main(String[] args) in B:\Programs\GitHub\RedBookPlayer\RedBookPlayer\Program.cs:line 14 ``` For example, the above was generated when playing a track with only indices 0 and 1, playing index 1, and then attempting to hit "Next Index". The fix for this is to enable earlier boundary checking. If the setting mentioned above is enabled, this should go to the next track, otherwise, the button should do nothing.
claunia added the bug label 2026-01-30 21:22:46 +00:00
Author
Owner

@mnadareski commented on GitHub (Jun 5, 2021):

There is also a similar, related issue that happens if you press "Previous Index" at the first index of a track.

@mnadareski commented on GitHub (Jun 5, 2021): There is also a similar, related issue that happens if you press "Previous Index" at the first index of a track.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: aaru-dps/RedBookPlayer#3