mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-06 07:29:42 +00:00
Compare commits
1 Commits
d1f62b7322
...
717252768f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
717252768f |
@ -5,7 +5,6 @@ import 'package:shadcn_flutter/shadcn_flutter.dart';
|
|||||||
|
|
||||||
import 'package:shadcn_flutter/shadcn_flutter_extension.dart';
|
import 'package:shadcn_flutter/shadcn_flutter_extension.dart';
|
||||||
import 'package:spotube/collections/assets.gen.dart';
|
import 'package:spotube/collections/assets.gen.dart';
|
||||||
import 'package:spotube/collections/routes.dart';
|
|
||||||
import 'package:spotube/collections/spotube_icons.dart';
|
import 'package:spotube/collections/spotube_icons.dart';
|
||||||
import 'package:spotube/components/ui/button_tile.dart';
|
import 'package:spotube/components/ui/button_tile.dart';
|
||||||
import 'package:spotube/extensions/constrains.dart';
|
import 'package:spotube/extensions/constrains.dart';
|
||||||
@ -60,7 +59,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.delete,
|
TrackOptionValue.delete,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -74,7 +73,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.album,
|
TrackOptionValue.album,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -98,7 +97,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.addToQueue,
|
TrackOptionValue.addToQueue,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -111,7 +110,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.playNext,
|
TrackOptionValue.playNext,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -125,7 +124,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.removeFromQueue,
|
TrackOptionValue.removeFromQueue,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -140,7 +139,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.favorite,
|
TrackOptionValue.favorite,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -163,7 +162,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.startRadio,
|
TrackOptionValue.startRadio,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -176,7 +175,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.addToPlaylist,
|
TrackOptionValue.addToPlaylist,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -191,7 +190,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.removeFromPlaylist,
|
TrackOptionValue.removeFromPlaylist,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -205,7 +204,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.download,
|
TrackOptionValue.download,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -227,7 +226,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.blacklist,
|
TrackOptionValue.blacklist,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -251,7 +250,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.share,
|
TrackOptionValue.share,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -265,7 +264,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.songlink,
|
TrackOptionValue.songlink,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
@ -283,7 +282,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await trackOptionActions.action(
|
await trackOptionActions.action(
|
||||||
rootNavigatorKey.currentContext!,
|
context,
|
||||||
TrackOptionValue.details,
|
TrackOptionValue.details,
|
||||||
playlistId,
|
playlistId,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/material.dart' show Badge;
|
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||||
@ -84,20 +83,14 @@ class GettingStartedPagePlaybackSection extends HookConsumerWidget {
|
|||||||
runSpacing: 6,
|
runSpacing: 6,
|
||||||
children: [
|
children: [
|
||||||
for (final source in AudioSource.values)
|
for (final source in AudioSource.values)
|
||||||
Badge(
|
RadioCard(
|
||||||
isLabelVisible: source == AudioSource.dabMusic,
|
value: source,
|
||||||
label: const Text("NEW"),
|
child: Column(
|
||||||
backgroundColor: Colors.lime[300],
|
mainAxisSize: MainAxisSize.min,
|
||||||
textColor: Colors.black,
|
children: [
|
||||||
child: RadioCard(
|
audioSourceToIconMap[source]!,
|
||||||
value: source,
|
Text(source.label),
|
||||||
child: Column(
|
],
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
audioSourceToIconMap[source]!,
|
|
||||||
Text(source.label),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -259,14 +259,11 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
|
|||||||
return addTracks(tracks);
|
return addTracks(tracks);
|
||||||
}
|
}
|
||||||
|
|
||||||
final addableTracks = _blacklist
|
final addableTracks = _blacklist.filter(tracks).where(
|
||||||
.filter(tracks)
|
|
||||||
.where(
|
|
||||||
(track) =>
|
(track) =>
|
||||||
allowDuplicates ||
|
allowDuplicates ||
|
||||||
!state.tracks.any((element) => _compareTracks(element, track)),
|
!state.tracks.any((element) => _compareTracks(element, track)),
|
||||||
)
|
);
|
||||||
.toList();
|
|
||||||
|
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
tracks: [...addableTracks, ...state.tracks],
|
tracks: [...addableTracks, ...state.tracks],
|
||||||
@ -374,12 +371,13 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool _compareTracks(SpotubeTrackObject a, SpotubeTrackObject b) {
|
bool _compareTracks(SpotubeTrackObject a, SpotubeTrackObject b) {
|
||||||
if (a.runtimeType != b.runtimeType) {
|
if ((a is SpotubeLocalTrackObject && b is! SpotubeLocalTrackObject) ||
|
||||||
|
(a is! SpotubeLocalTrackObject && b is SpotubeLocalTrackObject)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return a is SpotubeLocalTrackObject && b is SpotubeLocalTrackObject
|
return a is SpotubeLocalTrackObject && b is SpotubeLocalTrackObject
|
||||||
? a.path == b.path
|
? (a).path == (b).path
|
||||||
: a.id == b.id;
|
: a.id == b.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -214,7 +214,7 @@ class MetadataPluginNotifier extends AsyncNotifier<MetadataPluginState> {
|
|||||||
/// Root directory where all metadata plugins are stored.
|
/// Root directory where all metadata plugins are stored.
|
||||||
Future<Directory> _getPluginRootDir() async => Directory(
|
Future<Directory> _getPluginRootDir() async => Directory(
|
||||||
join(
|
join(
|
||||||
(await getApplicationSupportDirectory()).path,
|
(await getApplicationCacheDirectory()).path,
|
||||||
"metadata-plugins",
|
"metadata-plugins",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -166,7 +166,7 @@ class TrackOptionsActions {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TrackOptionValue.playNext:
|
case TrackOptionValue.playNext:
|
||||||
await playback.addTracksAtFirst([track]);
|
playback.addTracksAtFirst([track]);
|
||||||
|
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
showToast(
|
showToast(
|
||||||
|
|||||||
@ -57,7 +57,6 @@ abstract class AudioPlayerInterface {
|
|||||||
title: "Spotube",
|
title: "Spotube",
|
||||||
logLevel: kDebugMode ? mk.MPVLogLevel.info : mk.MPVLogLevel.error,
|
logLevel: kDebugMode ? mk.MPVLogLevel.info : mk.MPVLogLevel.error,
|
||||||
bufferSize: 4 * 1024 * 1024, // 4MB buffer
|
bufferSize: 4 * 1024 * 1024, // 4MB buffer
|
||||||
async: true,
|
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
_mkPlayer.stream.error.listen((event) {
|
_mkPlayer.stream.error.listen((event) {
|
||||||
|
|||||||
@ -121,23 +121,9 @@ class CustomPlayer extends Player {
|
|||||||
NativePlayer get nativePlayer => platform as NativePlayer;
|
NativePlayer get nativePlayer => platform as NativePlayer;
|
||||||
|
|
||||||
Future<void> insert(int index, Media media) async {
|
Future<void> insert(int index, Media media) async {
|
||||||
final addedMediaCompleter = Completer<int>();
|
await add(media);
|
||||||
final playlistStream = stream.playlist.listen(
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
(event) {
|
await move(state.playlist.medias.length - 1, index);
|
||||||
final mediaAddedIndex =
|
|
||||||
event.medias.indexWhere((m) => m.uri == media.uri);
|
|
||||||
if (mediaAddedIndex != -1 && !addedMediaCompleter.isCompleted) {
|
|
||||||
addedMediaCompleter.complete(mediaAddedIndex);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
await add(media);
|
|
||||||
final mediaAddedIndex = await addedMediaCompleter.future;
|
|
||||||
await move(mediaAddedIndex, index);
|
|
||||||
} finally {
|
|
||||||
playlistStream.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setAudioNormalization(bool normalize) async {
|
Future<void> setAudioNormalization(bool normalize) async {
|
||||||
|
|||||||
@ -1,12 +1,8 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:drift/drift.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:spotube/models/database/database.dart';
|
import 'package:spotube/models/database/database.dart';
|
||||||
import 'package:spotube/models/playback/track_sources.dart';
|
import 'package:spotube/models/playback/track_sources.dart';
|
||||||
import 'package:spotube/provider/database/database.dart';
|
|
||||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||||
import 'package:spotube/services/logger/logger.dart';
|
import 'package:spotube/services/logger/logger.dart';
|
||||||
import 'package:spotube/services/sourced_track/enums.dart';
|
import 'package:spotube/services/sourced_track/enums.dart';
|
||||||
@ -36,68 +32,11 @@ class DABMusicSourcedTrack extends SourcedTrack {
|
|||||||
required Ref ref,
|
required Ref ref,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
final database = ref.read(databaseProvider);
|
|
||||||
final cachedSource = await (database.select(database.sourceMatchTable)
|
|
||||||
..where((s) => s.trackId.equals(query.id))
|
|
||||||
..limit(1)
|
|
||||||
..orderBy([
|
|
||||||
(s) => OrderingTerm(
|
|
||||||
expression: s.createdAt,
|
|
||||||
mode: OrderingMode.desc,
|
|
||||||
),
|
|
||||||
]))
|
|
||||||
.get()
|
|
||||||
.then((s) => s.firstOrNull);
|
|
||||||
|
|
||||||
if (cachedSource != null &&
|
|
||||||
cachedSource.sourceType == SourceType.dabMusic) {
|
|
||||||
final json = jsonDecode(cachedSource.sourceId);
|
|
||||||
final info = TrackSourceInfo.fromJson(json["info"]);
|
|
||||||
final source = (json["sources"] as List?)
|
|
||||||
?.map((s) => TrackSource.fromJson(s))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
final [updatedSource] = await fetchSources(
|
|
||||||
info.id,
|
|
||||||
ref.read(userPreferencesProvider).audioQuality,
|
|
||||||
const AudioQuality(
|
|
||||||
isHiRes: true,
|
|
||||||
maximumBitDepth: 16,
|
|
||||||
maximumSamplingRate: 44.1,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return DABMusicSourcedTrack(
|
|
||||||
ref: ref,
|
|
||||||
source: AudioSource.dabMusic,
|
|
||||||
siblings: [],
|
|
||||||
info: info,
|
|
||||||
query: query,
|
|
||||||
sources: [
|
|
||||||
source!.first.copyWith(url: updatedSource.url),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final siblings = await fetchSiblings(ref: ref, query: query);
|
final siblings = await fetchSiblings(ref: ref, query: query);
|
||||||
|
|
||||||
if (siblings.isEmpty) {
|
if (siblings.isEmpty) {
|
||||||
throw TrackNotFoundError(query);
|
throw TrackNotFoundError(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
await database.into(database.sourceMatchTable).insert(
|
|
||||||
SourceMatchTableCompanion.insert(
|
|
||||||
trackId: query.id,
|
|
||||||
sourceId: jsonEncode({
|
|
||||||
"info": siblings.first.info.toJson(),
|
|
||||||
"sources": (siblings.first.source ?? [])
|
|
||||||
.map((s) => s.toJson())
|
|
||||||
.toList(),
|
|
||||||
}),
|
|
||||||
sourceType: const Value(SourceType.dabMusic),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return DABMusicSourcedTrack(
|
return DABMusicSourcedTrack(
|
||||||
ref: ref,
|
ref: ref,
|
||||||
siblings: siblings.map((s) => s.info).skip(1).toList(),
|
siblings: siblings.map((s) => s.info).skip(1).toList(),
|
||||||
@ -268,23 +207,6 @@ class DABMusicSourcedTrack extends SourcedTrack {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final database = ref.read(databaseProvider);
|
|
||||||
|
|
||||||
await database.into(database.sourceMatchTable).insert(
|
|
||||||
SourceMatchTableCompanion.insert(
|
|
||||||
trackId: query.id,
|
|
||||||
sourceId: jsonEncode({
|
|
||||||
"info": newSourceInfo.toJson(),
|
|
||||||
"sources": source.map((s) => s.toJson()).toList(),
|
|
||||||
}),
|
|
||||||
sourceType: const Value(SourceType.dabMusic),
|
|
||||||
// Because we're sorting by createdAt in the query
|
|
||||||
// we have to update it to indicate priority
|
|
||||||
createdAt: Value(DateTime.now()),
|
|
||||||
),
|
|
||||||
mode: InsertMode.replace,
|
|
||||||
);
|
|
||||||
|
|
||||||
return DABMusicSourcedTrack(
|
return DABMusicSourcedTrack(
|
||||||
ref: ref,
|
ref: ref,
|
||||||
siblings: newSiblings,
|
siblings: newSiblings,
|
||||||
|
|||||||
@ -1412,10 +1412,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: invidious
|
name: invidious
|
||||||
sha256: "0da8ebc4c4110057f03302bbd54514b10642154d7be569e7994172f2202dcfe8"
|
sha256: "27ef3a001df875665de15535dbc9099f44d12a59480018fb1e17377d4af0308d"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.2"
|
version: "0.1.1"
|
||||||
io:
|
io:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -81,7 +81,7 @@ dependencies:
|
|||||||
http: ^1.2.1
|
http: ^1.2.1
|
||||||
image_picker: ^1.1.0
|
image_picker: ^1.1.0
|
||||||
intl: any
|
intl: any
|
||||||
invidious: ^0.1.2
|
invidious: ^0.1.1
|
||||||
jiosaavn: ^0.1.0
|
jiosaavn: ^0.1.0
|
||||||
json_annotation: ^4.8.1
|
json_annotation: ^4.8.1
|
||||||
local_notifier: ^0.1.6
|
local_notifier: ^0.1.6
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user