Skip to content

Commit

Permalink
fix(playback): skipping tracks with unplayable sources instead of fal…
Browse files Browse the repository at this point in the history
…ling back #1492
  • Loading branch information
KRTirtho committed Jun 2, 2024
1 parent 56241f7 commit c607a33
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
8 changes: 1 addition & 7 deletions lib/services/sourced_track/sourced_track.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,10 @@ abstract class SourcedTrack extends Track {
return await PipedSourcedTrack.fetchFromTrack(track: track, ref: ref);
} catch (e) {
if (e is DioException || e is ClientException || e is SocketException) {
if (preferences.audioSource == AudioSource.jiosaavn) {
return await JioSaavnSourcedTrack.fetchFromTrack(
track: track,
ref: ref,
weakMatch: true,
);
}
return await JioSaavnSourcedTrack.fetchFromTrack(
track: track,
ref: ref,
weakMatch: preferences.audioSource == AudioSource.jiosaavn,
);
}
rethrow;
Expand Down
22 changes: 14 additions & 8 deletions lib/services/sourced_track/sources/youtube.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:catcher_2/core/catcher_2.dart';
import 'package:collection/collection.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:http/http.dart';
Expand Down Expand Up @@ -221,14 +222,19 @@ class YoutubeSourcedTrack extends SourcedTrack {
final ytLink = links.firstWhereOrNull((link) => link.platform == "youtube");

if (ytLink?.url != null) {
return [
await toSiblingType(
0,
YoutubeVideoInfo.fromVideo(
await youtubeClient.videos.get(ytLink!.url!),
),
)
];
try {
return [
await toSiblingType(
0,
YoutubeVideoInfo.fromVideo(
await youtubeClient.videos.get(ytLink!.url!),
),
)
];
} on VideoUnplayableException catch (e, stack) {
// Ignore this error and continue with the search
Catcher2.reportCheckedError(e, stack);
}
}

final query = SourcedTrack.getSearchTerm(track);
Expand Down
8 changes: 7 additions & 1 deletion lib/themes/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ ThemeData theme(Color seed, Brightness brightness, bool isAmoled) {
horizontalTitleGap: 5,
iconColor: scheme.onSurface,
),
appBarTheme: const AppBarTheme(surfaceTintColor: Colors.transparent),
appBarTheme: const AppBarTheme(
surfaceTintColor: Colors.transparent,
scrolledUnderElevation: 0,
shadowColor: Colors.transparent,
elevation: 0,
backgroundColor: Colors.transparent,
),
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
Expand Down

0 comments on commit c607a33

Please sign in to comment.