mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
Compare commits
9 Commits
935803a785
...
22745cf40f
Author | SHA1 | Date | |
---|---|---|---|
![]() |
22745cf40f | ||
![]() |
4ed40d95b2 | ||
![]() |
b24dcd2951 | ||
![]() |
8ff90bafd7 | ||
![]() |
9190af92ef | ||
![]() |
42e954428b | ||
![]() |
8c1337d1fc | ||
![]() |
94e704087f | ||
![]() |
8e287ab1e5 |
@ -9,7 +9,7 @@ import 'package:spotube/provider/history/recent.dart';
|
||||
|
||||
class HomeRecentlyPlayedSection extends HookConsumerWidget {
|
||||
const HomeRecentlyPlayedSection({super.key});
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, ref) {
|
||||
final history = ref.watch(recentlyPlayedItems);
|
||||
@ -20,17 +20,20 @@ class HomeRecentlyPlayedSection extends HookConsumerWidget {
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
final uniqueItems = <dynamic>{};
|
||||
final filteredItems = [
|
||||
for (final item in historyData)
|
||||
if (item.playlist != null && item.playlist?.id != null && uniqueItems.add(item.playlist!.id!))
|
||||
item.playlist
|
||||
else if (item.album != null && item.album?.id != null && uniqueItems.add(item.album?.id))
|
||||
item.album
|
||||
];
|
||||
|
||||
return Skeletonizer(
|
||||
enabled: history.isLoading,
|
||||
child: HorizontalPlaybuttonCardView(
|
||||
title: Text(context.l10n.recently_played),
|
||||
items: [
|
||||
for (final item in historyData)
|
||||
if (item.playlist != null)
|
||||
item.playlist
|
||||
else if (item.album != null)
|
||||
item.album
|
||||
],
|
||||
items: filteredItems,
|
||||
hasNextPage: false,
|
||||
isLoadingNextPage: false,
|
||||
onFetchMore: () {},
|
||||
|
@ -70,6 +70,7 @@ class SiblingTracksSheet extends HookConsumerWidget {
|
||||
final preferences = ref.watch(userPreferencesProvider);
|
||||
final youtubeEngine = ref.watch(youtubeEngineProvider);
|
||||
|
||||
final isLoading = useState(false);
|
||||
final isSearching = useState(false);
|
||||
final searchMode = useState(preferences.searchMode);
|
||||
final activeTrackSources = ref.watch(activeTrackSourcesProvider);
|
||||
@ -195,27 +196,40 @@ class SiblingTracksSheet extends HookConsumerWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
enabled: !isFetchingActiveTrack,
|
||||
enabled: !isFetchingActiveTrack && !isLoading.value,
|
||||
selected: !isFetchingActiveTrack &&
|
||||
sourceInfo.id == activeTrackSource?.info.id,
|
||||
onPressed: () async {
|
||||
if (!isFetchingActiveTrack &&
|
||||
sourceInfo.id != activeTrackSource?.info.id) {
|
||||
await activeTrackNotifier?.swapWithSibling(sourceInfo);
|
||||
await ref.read(audioPlayerProvider.notifier).swapActiveSource();
|
||||
try {
|
||||
isLoading.value = true;
|
||||
await activeTrackNotifier?.swapWithSibling(sourceInfo);
|
||||
await ref.read(audioPlayerProvider.notifier).swapActiveSource();
|
||||
|
||||
if (context.mounted) {
|
||||
if (MediaQuery.sizeOf(context).mdAndUp) {
|
||||
closeOverlay(context);
|
||||
} else {
|
||||
closeDrawer(context);
|
||||
if (context.mounted) {
|
||||
if (MediaQuery.sizeOf(context).mdAndUp) {
|
||||
closeOverlay(context);
|
||||
} else {
|
||||
closeDrawer(context);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (context.mounted) {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
[activeTrackSource, activeTrackNotifier, siblings],
|
||||
[
|
||||
activeTrackSource,
|
||||
activeTrackNotifier,
|
||||
siblings,
|
||||
isFetchingActiveTrack,
|
||||
isLoading.value,
|
||||
],
|
||||
);
|
||||
|
||||
final scale = context.theme.scaling;
|
||||
@ -293,6 +307,15 @@ class SiblingTracksSheet extends HookConsumerWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: isLoading.value
|
||||
? const SizedBox(
|
||||
width: double.infinity,
|
||||
child: LinearProgressIndicator(),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
Expanded(
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
@ -307,7 +330,9 @@ class SiblingTracksSheet extends HookConsumerWidget {
|
||||
itemCount: siblings.length,
|
||||
separatorBuilder: (context, index) => const Gap(8),
|
||||
itemBuilder: (context, index) => itemBuilder(
|
||||
siblings[index], activeTrackSource!.source),
|
||||
siblings[index],
|
||||
activeTrackSource!.source,
|
||||
),
|
||||
),
|
||||
true => FutureBuilder(
|
||||
future: searchRequest,
|
||||
|
@ -13,7 +13,6 @@ import 'package:spotube/l10n/l10n.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
|
||||
final localWithName = L10n.all.map((e) {
|
||||
print(e);
|
||||
final isoCodeName =
|
||||
LanguageLocals.getDisplayLanguage(e.languageCode, e.countryCode);
|
||||
return (
|
||||
|
@ -147,21 +147,29 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
|
||||
try {
|
||||
// Playlist and state has to be in sync. This is only meant for
|
||||
// the shuffle/re-ordering indices to be in sync
|
||||
if (playlist.medias.length != state.tracks.length) return;
|
||||
|
||||
final queries = playlist.medias
|
||||
.map((media) => TrackSourceQuery.parseUri(media.uri))
|
||||
.toList();
|
||||
if (playlist.medias.length != state.tracks.length) {
|
||||
AppLogger.log.w(
|
||||
"Playlist length does not match state tracks length. Ignoring... "
|
||||
"Playlist length: ${playlist.medias.length}, "
|
||||
"State tracks length: ${state.tracks.length}",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final trackGroupedById = groupBy(
|
||||
state.tracks,
|
||||
(query) => query.id,
|
||||
);
|
||||
|
||||
final tracks = queries
|
||||
.map((query) => trackGroupedById[query.id]?.firstOrNull)
|
||||
.nonNulls
|
||||
.toList();
|
||||
final tracks = <SpotubeTrackObject>[];
|
||||
|
||||
for (final media in playlist.medias) {
|
||||
final trackQuery = TrackSourceQuery.parseUri(media.uri);
|
||||
final track = trackGroupedById[trackQuery.id]?.firstOrNull;
|
||||
if (track != null) {
|
||||
tracks.add(track);
|
||||
}
|
||||
}
|
||||
|
||||
if (tracks.length != state.tracks.length) {
|
||||
AppLogger.log.w("Mismatch in tracks after reordering/shuffling.");
|
||||
|
@ -146,7 +146,5 @@ mixin SpotubeAudioPlayersStreams on AudioPlayerInterface {
|
||||
|
||||
Stream<String> get errorStream => _mkPlayer.stream.error;
|
||||
|
||||
Stream<mk.Playlist> get playlistStream => _mkPlayer.stream.playlist.map((s) {
|
||||
return s;
|
||||
});
|
||||
Stream<mk.Playlist> get playlistStream => _mkPlayer.stream.playlist;
|
||||
}
|
||||
|
@ -12,19 +12,15 @@ import 'package:spotube/utils/platform.dart';
|
||||
/// This class adds a state stream to the [Player] class.
|
||||
class CustomPlayer extends Player {
|
||||
final StreamController<AudioPlaybackState> _playerStateStream;
|
||||
final StreamController<bool> _shuffleStream;
|
||||
|
||||
late final List<StreamSubscription> _subscriptions;
|
||||
|
||||
bool _shuffled;
|
||||
int _androidAudioSessionId = 0;
|
||||
String _packageName = "";
|
||||
AndroidAudioManager? _androidAudioManager;
|
||||
|
||||
CustomPlayer({super.configuration})
|
||||
: _playerStateStream = StreamController.broadcast(),
|
||||
_shuffleStream = StreamController.broadcast(),
|
||||
_shuffled = false {
|
||||
: _playerStateStream = StreamController.broadcast() {
|
||||
nativePlayer.setProperty("network-timeout", "120");
|
||||
|
||||
_subscriptions = [
|
||||
@ -86,10 +82,10 @@ class CustomPlayer extends Player {
|
||||
}
|
||||
}
|
||||
|
||||
bool get shuffled => _shuffled;
|
||||
bool get shuffled => state.shuffle;
|
||||
|
||||
Stream<AudioPlaybackState> get playerStateStream => _playerStateStream.stream;
|
||||
Stream<bool> get shuffleStream => _shuffleStream.stream;
|
||||
Stream<bool> get shuffleStream => stream.shuffle;
|
||||
Stream<int> get indexChangeStream {
|
||||
int oldIndex = state.playlist.index;
|
||||
return stream.playlist.map((event) => event.index).where((newIndex) {
|
||||
@ -103,22 +99,14 @@ class CustomPlayer extends Player {
|
||||
|
||||
@override
|
||||
Future<void> setShuffle(bool shuffle) async {
|
||||
_shuffled = shuffle;
|
||||
await super.setShuffle(shuffle);
|
||||
_shuffleStream.add(shuffle);
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
if (shuffle) {
|
||||
await move(state.playlist.index, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> stop() async {
|
||||
await super.stop();
|
||||
|
||||
_shuffled = false;
|
||||
_playerStateStream.add(AudioPlaybackState.stopped);
|
||||
_shuffleStream.add(false);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -134,7 +122,8 @@ class CustomPlayer extends Player {
|
||||
|
||||
Future<void> insert(int index, Media media) async {
|
||||
await add(media);
|
||||
await move(state.playlist.medias.length, index);
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
await move(state.playlist.medias.length - 1, index);
|
||||
}
|
||||
|
||||
Future<void> setAudioNormalization(bool normalize) async {
|
||||
|
73
pubspec.lock
73
pubspec.lock
@ -1570,58 +1570,65 @@ packages:
|
||||
media_kit:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: media_kit
|
||||
sha256: "48c10c3785df5d88f0eef970743f8c99b2e5da2b34b9d8f9876e598f62d9e776"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: media_kit
|
||||
ref: HEAD
|
||||
resolved-ref: c9617f570b8c0ba02857e721997f78c053a856c1
|
||||
url: "https://github.com/media-kit/media-kit"
|
||||
source: git
|
||||
version: "1.2.0"
|
||||
media_kit_libs_android_audio:
|
||||
dependency: transitive
|
||||
dependency: "direct overridden"
|
||||
description:
|
||||
name: media_kit_libs_android_audio
|
||||
sha256: d0923d251c1232880e755b44555ce31b9e7068a29f05e01ed2fb510956bba851
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "libs/android/media_kit_libs_android_audio"
|
||||
ref: HEAD
|
||||
resolved-ref: c9617f570b8c0ba02857e721997f78c053a856c1
|
||||
url: "https://github.com/media-kit/media-kit"
|
||||
source: git
|
||||
version: "1.3.7"
|
||||
media_kit_libs_audio:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: media_kit_libs_audio
|
||||
sha256: f5ea1eb414c4ee4994f36de36c7ce11577a249e058e907e7eb6e656513bccbfb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "libs/universal/media_kit_libs_audio"
|
||||
ref: HEAD
|
||||
resolved-ref: c9617f570b8c0ba02857e721997f78c053a856c1
|
||||
url: "https://github.com/media-kit/media-kit"
|
||||
source: git
|
||||
version: "1.0.6"
|
||||
media_kit_libs_ios_audio:
|
||||
dependency: transitive
|
||||
dependency: "direct overridden"
|
||||
description:
|
||||
name: media_kit_libs_ios_audio
|
||||
sha256: "78ccf04e27d6b4ba00a355578ccb39b772f00d48269a6ac3db076edf2d51934f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "libs/ios/media_kit_libs_ios_audio"
|
||||
ref: HEAD
|
||||
resolved-ref: c9617f570b8c0ba02857e721997f78c053a856c1
|
||||
url: "https://github.com/media-kit/media-kit"
|
||||
source: git
|
||||
version: "1.1.4"
|
||||
media_kit_libs_linux:
|
||||
dependency: transitive
|
||||
dependency: "direct overridden"
|
||||
description:
|
||||
name: media_kit_libs_linux
|
||||
sha256: "2b473399a49ec94452c4d4ae51cfc0f6585074398d74216092bf3d54aac37ecf"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "libs/linux/media_kit_libs_linux"
|
||||
ref: HEAD
|
||||
resolved-ref: c9617f570b8c0ba02857e721997f78c053a856c1
|
||||
url: "https://github.com/media-kit/media-kit"
|
||||
source: git
|
||||
version: "1.2.1"
|
||||
media_kit_libs_macos_audio:
|
||||
dependency: transitive
|
||||
dependency: "direct overridden"
|
||||
description:
|
||||
name: media_kit_libs_macos_audio
|
||||
sha256: "3be21844df98f286de32808592835073cdef2c1a10078bac135da790badca950"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "libs/macos/media_kit_libs_macos_audio"
|
||||
ref: HEAD
|
||||
resolved-ref: c9617f570b8c0ba02857e721997f78c053a856c1
|
||||
url: "https://github.com/media-kit/media-kit"
|
||||
source: git
|
||||
version: "1.1.4"
|
||||
media_kit_libs_windows_audio:
|
||||
dependency: transitive
|
||||
dependency: "direct overridden"
|
||||
description:
|
||||
name: media_kit_libs_windows_audio
|
||||
sha256: c2fd558cc87b9d89a801141fcdffe02e338a3b21a41a18fbd63d5b221a1b8e53
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
path: "libs/windows/media_kit_libs_windows_audio"
|
||||
ref: HEAD
|
||||
resolved-ref: c9617f570b8c0ba02857e721997f78c053a856c1
|
||||
url: "https://github.com/media-kit/media-kit"
|
||||
source: git
|
||||
version: "1.0.9"
|
||||
menu_base:
|
||||
dependency: transitive
|
||||
|
30
pubspec.yaml
30
pubspec.yaml
@ -84,8 +84,14 @@ dependencies:
|
||||
logger: ^2.0.2
|
||||
logging: ^1.3.0
|
||||
lrc: ^1.0.2
|
||||
media_kit: ^1.1.10+1
|
||||
media_kit_libs_audio: ^1.0.4
|
||||
media_kit:
|
||||
git:
|
||||
url: https://github.com/media-kit/media-kit
|
||||
path: media_kit
|
||||
media_kit_libs_audio:
|
||||
git:
|
||||
url: https://github.com/media-kit/media-kit
|
||||
path: libs/universal/media_kit_libs_audio
|
||||
metadata_god: ^1.1.0
|
||||
mime: ^2.0.0
|
||||
open_file: ^3.5.10
|
||||
@ -194,6 +200,26 @@ dependency_overrides:
|
||||
ref: patch-2
|
||||
path: flutter_secure_storage_linux
|
||||
flutter_secure_storage_platform_interface: 2.0.0
|
||||
media_kit_libs_android_audio:
|
||||
git:
|
||||
url: https://github.com/media-kit/media-kit
|
||||
path: libs/android/media_kit_libs_android_audio
|
||||
media_kit_libs_ios_audio:
|
||||
git:
|
||||
url: https://github.com/media-kit/media-kit
|
||||
path: libs/ios/media_kit_libs_ios_audio
|
||||
media_kit_libs_macos_audio:
|
||||
git:
|
||||
url: https://github.com/media-kit/media-kit
|
||||
path: libs/macos/media_kit_libs_macos_audio
|
||||
media_kit_libs_windows_audio:
|
||||
git:
|
||||
url: https://github.com/media-kit/media-kit
|
||||
path: libs/windows/media_kit_libs_windows_audio
|
||||
media_kit_libs_linux:
|
||||
git:
|
||||
url: https://github.com/media-kit/media-kit
|
||||
path: libs/linux/media_kit_libs_linux
|
||||
|
||||
flutter:
|
||||
generate: true
|
||||
|
Loading…
Reference in New Issue
Block a user