fix(playback): skipping tracks with unplayable sources instead of falling back #1492

This commit is contained in:
Kingkor Roy Tirtho 2024-06-02 22:34:06 +06:00
parent 56241f773a
commit c607a330ed
3 changed files with 22 additions and 16 deletions

View File

@ -135,16 +135,10 @@ abstract class SourcedTrack extends Track {
return await PipedSourcedTrack.fetchFromTrack(track: track, ref: ref); return await PipedSourcedTrack.fetchFromTrack(track: track, ref: ref);
} catch (e) { } catch (e) {
if (e is DioException || e is ClientException || e is SocketException) { 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( return await JioSaavnSourcedTrack.fetchFromTrack(
track: track, track: track,
ref: ref, ref: ref,
weakMatch: preferences.audioSource == AudioSource.jiosaavn,
); );
} }
rethrow; rethrow;

View File

@ -1,3 +1,4 @@
import 'package:catcher_2/core/catcher_2.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
@ -221,14 +222,19 @@ class YoutubeSourcedTrack extends SourcedTrack {
final ytLink = links.firstWhereOrNull((link) => link.platform == "youtube"); final ytLink = links.firstWhereOrNull((link) => link.platform == "youtube");
if (ytLink?.url != null) { if (ytLink?.url != null) {
return [ try {
await toSiblingType( return [
0, await toSiblingType(
YoutubeVideoInfo.fromVideo( 0,
await youtubeClient.videos.get(ytLink!.url!), 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); final query = SourcedTrack.getSearchTerm(track);

View File

@ -24,7 +24,13 @@ ThemeData theme(Color seed, Brightness brightness, bool isAmoled) {
horizontalTitleGap: 5, horizontalTitleGap: 5,
iconColor: scheme.onSurface, 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( inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),