@@ -389,6 +389,7 @@ private void UpdateSongBox()
389389 SongBox . ItemsSource = _playablesManager . PlayingPlayable ? . PlayQueue . Tracks
390390 . Where ( track => ! string . IsNullOrEmpty ( track . Metadata . TrackName ) ) . ToList ( )
391391 . Select ( track => PostProcessedText ( track . Metadata . TrackName , 20 ) ) ;
392+ SortSongBox ( ) ;
392393 }
393394
394395 private void UpdateTrackPositionSlider ( )
@@ -497,19 +498,47 @@ private void SongBox_OnSelectionChanged(object? sender, TappedEventArgs tappedEv
497498 var castedSender = ( ListBox ) sender ! ;
498499 _logger . LogInformation ( castedSender . SelectedIndex . ToString ( ) ) ;
499500 var selectedIndex = castedSender . SelectedIndex ;
500- var selectedTrack = _playablesManager . PlayingPlayable ? . PlayQueue . Tracks [ selectedIndex ] ;
501+
502+
503+ var sortedQueue = string . IsNullOrEmpty ( SongBoxFindText . Text )
504+ ? _playablesManager . PlayingPlayable ! . PlayQueue . Tracks
505+ : _playablesManager . PlayingPlayable ? . PlayQueue . Tracks . Where ( i =>
506+ i . Metadata . TrackName ! . Contains ( SongBoxFindText . Text ! ,
507+ StringComparison . CurrentCultureIgnoreCase ) )
508+ . ToList ( ) ! ;
509+
510+ var selectedTrack = sortedQueue [ selectedIndex ] ;
501511 if ( selectedTrack != null )
502- _playablesManager . ForceStartTrackByIndex ( selectedIndex ) ;
512+ _playablesManager . ForceStartTrack ( selectedTrack ) ;
503513 else
504514 _logger . LogError ( "No track selected" ) ;
505515 castedSender . Selection = null ! ;
516+ SortSongBox ( ) ;
506517 }
507518 catch ( Exception ex )
508519 {
509520 _logger . LogError ( "Error while force starting song: {ex}" , ex . Message ) ;
510521 }
511522 }
512523
524+ private void SongBoxFindText_OnTextChanged ( object ? sender , TextChangedEventArgs e )
525+ {
526+ SortSongBox ( ) ;
527+ }
528+
529+ private void SortSongBox ( )
530+ {
531+ if ( string . IsNullOrEmpty ( SongBoxFindText . Text ) )
532+ {
533+ SongBox . ItemsSource = _playablesManager . PlayingPlayable ? . PlayQueue . Tracks . Select ( x => x . Metadata . TrackName ) . ToList ( ) ;
534+ return ;
535+ }
536+ SongBox . ItemsSource = _playablesManager . PlayingPlayable ? . PlayQueue . Tracks
537+ . Where ( track => ! string . IsNullOrEmpty ( track . Metadata . TrackName ) ) . ToList ( ) . Where ( i =>
538+ i . Metadata . TrackName ! . Contains ( SongBoxFindText . Text ! , StringComparison . CurrentCultureIgnoreCase ) )
539+ . Select ( track => PostProcessedText ( track . Metadata . TrackName , 20 ) ) ;
540+ }
541+
513542 private string PostProcessedText ( string ? enterText , int maxSymbols )
514543 {
515544 try
0 commit comments