mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
fix: youtube source taking too long to buffer
This commit is contained in:
parent
b1780e0cf8
commit
043eaba81f
@ -93,6 +93,7 @@ class PlayerControls extends HookConsumerWidget {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: mediaQuery.xlAndUp ? 600 : 500,
|
width: mediaQuery.xlAndUp ? 600 : 500,
|
||||||
child: Slider(
|
child: Slider(
|
||||||
|
hintValue: SliderValue.single(bufferProgress),
|
||||||
value:
|
value:
|
||||||
SliderValue.single(progress.value.toDouble()),
|
SliderValue.single(progress.value.toDouble()),
|
||||||
onChanged: isFetchingActiveTrack
|
onChanged: isFetchingActiveTrack
|
||||||
|
@ -128,7 +128,7 @@ class AboutSpotubePage extends HookConsumerWidget {
|
|||||||
colon,
|
colon,
|
||||||
const TableCell(
|
const TableCell(
|
||||||
child: Hyperlink(
|
child: Hyperlink(
|
||||||
"Discord",
|
"Discord#chat",
|
||||||
"https://discord.gg/uJ94vxB6vg",
|
"https://discord.gg/uJ94vxB6vg",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:http/http.dart';
|
|
||||||
import 'package:spotify/spotify.dart';
|
import 'package:spotify/spotify.dart';
|
||||||
import 'package:spotube/models/database/database.dart';
|
import 'package:spotube/models/database/database.dart';
|
||||||
import 'package:spotube/provider/database/database.dart';
|
import 'package:spotube/provider/database/database.dart';
|
||||||
@ -44,6 +43,18 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
required super.ref,
|
required super.ref,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static Future<StreamManifest> _getStreamManifest(String id) async {
|
||||||
|
return youtubeClient.videos.streamsClient.getManifest(
|
||||||
|
id,
|
||||||
|
requireWatchPage: false,
|
||||||
|
ytClients: [
|
||||||
|
YoutubeApiClient.android,
|
||||||
|
YoutubeApiClient.mweb,
|
||||||
|
YoutubeApiClient.safari,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static Future<YoutubeSourcedTrack> fetchFromTrack({
|
static Future<YoutubeSourcedTrack> fetchFromTrack({
|
||||||
required Track track,
|
required Track track,
|
||||||
required Ref ref,
|
required Ref ref,
|
||||||
@ -82,17 +93,7 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
final item = await youtubeClient.videos.get(cachedSource.sourceId);
|
final item = await youtubeClient.videos.get(cachedSource.sourceId);
|
||||||
final manifest = await youtubeClient.videos.streamsClient.getManifest(
|
final manifest = await _getStreamManifest(cachedSource.sourceId);
|
||||||
cachedSource.sourceId,
|
|
||||||
requireWatchPage: false,
|
|
||||||
ytClients: [
|
|
||||||
YoutubeApiClient.mediaConnect,
|
|
||||||
YoutubeApiClient.ios,
|
|
||||||
YoutubeApiClient.android,
|
|
||||||
YoutubeApiClient.mweb,
|
|
||||||
YoutubeApiClient.tv,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
return YoutubeSourcedTrack(
|
return YoutubeSourcedTrack(
|
||||||
ref: ref,
|
ref: ref,
|
||||||
siblings: [],
|
siblings: [],
|
||||||
@ -144,17 +145,7 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
) async {
|
) async {
|
||||||
SourceMap? sourceMap;
|
SourceMap? sourceMap;
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
final manifest = await youtubeClient.videos.streamsClient.getManifest(
|
final manifest = await _getStreamManifest(item.id);
|
||||||
item.id,
|
|
||||||
requireWatchPage: false,
|
|
||||||
ytClients: [
|
|
||||||
YoutubeApiClient.mediaConnect,
|
|
||||||
YoutubeApiClient.ios,
|
|
||||||
YoutubeApiClient.android,
|
|
||||||
YoutubeApiClient.mweb,
|
|
||||||
YoutubeApiClient.tv,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
sourceMap = toSourceMap(manifest);
|
sourceMap = toSourceMap(manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,12 +285,7 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
final newSiblings = siblings.where((s) => s.id != sibling.id).toList()
|
final newSiblings = siblings.where((s) => s.id != sibling.id).toList()
|
||||||
..insert(0, sourceInfo);
|
..insert(0, sourceInfo);
|
||||||
|
|
||||||
final manifest = await youtubeClient.videos.streamsClient
|
final manifest = await _getStreamManifest(newSourceInfo.id);
|
||||||
.getManifest(newSourceInfo.id)
|
|
||||||
.timeout(
|
|
||||||
const Duration(seconds: 5),
|
|
||||||
onTimeout: () => throw ClientException("Timeout"),
|
|
||||||
);
|
|
||||||
|
|
||||||
final database = ref.read(databaseProvider);
|
final database = ref.read(databaseProvider);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user