mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
Playback track search retry-able now
Search page not rendering fix
This commit is contained in:
parent
e2bba4ac94
commit
c51a9a4c28
@ -67,7 +67,7 @@ class PlayerView extends HookConsumerWidget {
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15),
|
||||
child: Container(
|
||||
child: Material(
|
||||
color: paletteColor.color.withOpacity(.5),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
|
@ -37,8 +37,8 @@ class Search extends HookConsumerWidget {
|
||||
}
|
||||
final searchSnapshot = ref.watch(searchQuery(searchTerm));
|
||||
|
||||
return SafeArea(
|
||||
child: Expanded(
|
||||
return Expanded(
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: Column(
|
||||
|
@ -177,6 +177,8 @@ class TrackTile extends HookConsumerWidget {
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(isActive ? 10 : 0),
|
||||
),
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
@ -211,7 +213,8 @@ class TrackTile extends HookConsumerWidget {
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
playback.track?.id != null && playback.track?.id == track.value.id
|
||||
playback.track?.id != null &&
|
||||
playback.track?.id == track.value.id
|
||||
? Icons.pause_circle_rounded
|
||||
: Icons.play_circle_rounded,
|
||||
color: Theme.of(context).primaryColor,
|
||||
@ -323,6 +326,7 @@ class TrackTile extends HookConsumerWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:async/async.dart';
|
||||
import 'package:audio_service/audio_service.dart';
|
||||
import 'package:audioplayers/audioplayers.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
@ -227,6 +228,27 @@ class Playback extends PersistedChangeNotifier {
|
||||
player.dispose();
|
||||
}
|
||||
|
||||
Future<T> retryingOperation<T>(
|
||||
Future<T> Function() inner, {
|
||||
Duration? timeout,
|
||||
}) async {
|
||||
T result;
|
||||
try {
|
||||
final operation = CancelableOperation.fromFuture(inner());
|
||||
result = await operation.value;
|
||||
await Future.delayed(timeout ?? const Duration(seconds: 5), () async {
|
||||
if (!operation.isCompleted) {
|
||||
operation.cancel();
|
||||
result = await inner();
|
||||
}
|
||||
});
|
||||
return result;
|
||||
} catch (e) {
|
||||
result = await inner();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// playlist & track list methods
|
||||
Future<SpotubeTrack> toSpotubeTrack(Track track) async {
|
||||
final format = preferences.ytSearchFormat;
|
||||
@ -260,7 +282,8 @@ class Playback extends PersistedChangeNotifier {
|
||||
);
|
||||
ytVideo = VideoFromCacheTrackExtension.fromCacheTrack(cachedTrack);
|
||||
} else {
|
||||
VideoSearchList videos = await youtube.search.search(queryString);
|
||||
VideoSearchList videos =
|
||||
await retryingOperation(() => youtube.search.search(queryString));
|
||||
if (matchAlgorithm != SpotubeTrackMatchAlgorithm.youtube) {
|
||||
List<Map> ratedRankedVideos = videos
|
||||
.map((video) {
|
||||
@ -310,7 +333,9 @@ class Playback extends PersistedChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
final trackManifest = await youtube.videos.streams.getManifest(ytVideo.id);
|
||||
StreamManifest trackManifest = await retryingOperation(
|
||||
() => youtube.videos.streams.getManifest(ytVideo.id),
|
||||
);
|
||||
|
||||
_logger.v(
|
||||
"[YouTube Matched Track] ${ytVideo.title} | ${ytVideo.author} - ${ytVideo.url}",
|
||||
|
@ -37,7 +37,7 @@ packages:
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
async:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
|
@ -64,6 +64,7 @@ dependencies:
|
||||
dbus: ^0.7.3
|
||||
audioplayers: ^1.0.1
|
||||
resizable_widget: ^1.0.5
|
||||
async: ^2.8.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
Reference in New Issue
Block a user