@@ -547,7 +547,7 @@ private void SetNowPlayingSong()
547547 }
548548 }
549549
550- public async Task < Mediafile > GetUpcomingSong ( bool isNext = false )
550+ public async Task < Mediafile > GetUpcomingSong ( bool isNext = false , bool raiseException = true )
551551 {
552552 var playingCollection = GetPlayingCollection ( ) ;
553553 NowPlayingQueue = playingCollection ;
@@ -579,7 +579,7 @@ public async Task<Mediafile> GetUpcomingSong(bool isNext = false)
579579 }
580580 else
581581 {
582- if ( playingCollection [ _indexOfCurrentlyPlayingFile + 1 ] != null )
582+ if ( playingCollection . Count <= _indexOfCurrentlyPlayingFile + 1 )
583583 {
584584 toPlayFile = _indexOfCurrentlyPlayingFile <= playingCollection . Count - 2 && _indexOfCurrentlyPlayingFile != - 1
585585 ? playingCollection [ _indexOfCurrentlyPlayingFile + 1 ]
@@ -592,10 +592,13 @@ public async Task<Mediafile> GetUpcomingSong(bool isNext = false)
592592 }
593593 catch ( Exception ex )
594594 {
595- BLogger . E ( string . Format ( "An error occured while trying to play next song. IsShuffle: {0} IsSourceGrouped: {1}" , Shuffle , IsSourceGrouped ) , ex ) ;
596- await SharedLogic . Instance . NotificationManager . ShowMessageAsync ( "An error occured while trying to play next song. Trying again..." ) ;
597- ClearPlayerState ( ) ;
598- PlayNext ( ) ;
595+ if ( raiseException )
596+ {
597+ BLogger . E ( string . Format ( "An error occured while trying to play next song. IsShuffle: {0} IsSourceGrouped: {1}" , Shuffle , IsSourceGrouped ) , ex ) ;
598+ await SharedLogic . Instance . NotificationManager . ShowMessageAsync ( "An error occured while trying to play next song. Trying again..." ) ;
599+ ClearPlayerState ( ) ;
600+ PlayNext ( ) ;
601+ }
599602 }
600603 }
601604 return null ;
@@ -1168,9 +1171,6 @@ public async Task Load(Mediafile mp3File, bool play = false, double currentPos =
11681171 else
11691172 {
11701173 BLogger . I ( "Failed to load file. Loading next file..." ) ;
1171- var playingCollection = GetPlayingCollection ( ) ;
1172- int indexoferrorfile = playingCollection . IndexOf ( playingCollection . FirstOrDefault ( t => t . Path == mp3File . Path ) ) ;
1173- UpdateCurrentlyPlayingSongIndex ( ) ;
11741174 await Load ( await GetUpcomingSong ( true ) , true ) ;
11751175 }
11761176
0 commit comments