mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix(windows): local tracks plays but disabled playback controls
This commit is contained in:
parent
b5f3894983
commit
1c66646798
@ -37,9 +37,10 @@ class LocalLibraryPage extends HookConsumerWidget {
|
|||||||
currentTrack ??= tracks.first;
|
currentTrack ??= tracks.first;
|
||||||
final isPlaylistPlaying = playlist.containsTracks(tracks);
|
final isPlaylistPlaying = playlist.containsTracks(tracks);
|
||||||
if (!isPlaylistPlaying) {
|
if (!isPlaylistPlaying) {
|
||||||
|
var indexWhere = tracks.indexWhere((s) => s.id == currentTrack?.id);
|
||||||
await playback.load(
|
await playback.load(
|
||||||
tracks,
|
tracks,
|
||||||
initialIndex: tracks.indexWhere((s) => s.id == currentTrack?.id),
|
initialIndex: indexWhere,
|
||||||
autoPlay: true,
|
autoPlay: true,
|
||||||
);
|
);
|
||||||
} else if (isPlaylistPlaying &&
|
} else if (isPlaylistPlaying &&
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:media_kit/media_kit.dart' hide Track;
|
import 'package:media_kit/media_kit.dart' hide Track;
|
||||||
@ -11,6 +12,7 @@ import 'package:spotube/provider/audio_player/state.dart';
|
|||||||
import 'package:spotube/provider/blacklist_provider.dart';
|
import 'package:spotube/provider/blacklist_provider.dart';
|
||||||
import 'package:spotube/provider/database/database.dart';
|
import 'package:spotube/provider/database/database.dart';
|
||||||
import 'package:spotube/provider/discord_provider.dart';
|
import 'package:spotube/provider/discord_provider.dart';
|
||||||
|
import 'package:spotube/provider/local_tracks/local_tracks_provider.dart';
|
||||||
import 'package:spotube/provider/server/sourced_track.dart';
|
import 'package:spotube/provider/server/sourced_track.dart';
|
||||||
import 'package:spotube/services/audio_player/audio_player.dart';
|
import 'package:spotube/services/audio_player/audio_player.dart';
|
||||||
|
|
||||||
@ -283,7 +285,7 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
|
|||||||
// Giving the initial track a boost so MediaKit won't skip
|
// Giving the initial track a boost so MediaKit won't skip
|
||||||
// because of timeout
|
// because of timeout
|
||||||
final intendedActiveTrack = medias.elementAt(initialIndex);
|
final intendedActiveTrack = medias.elementAt(initialIndex);
|
||||||
if (intendedActiveTrack is! LocalTrack) {
|
if (intendedActiveTrack.track is! LocalTrack) {
|
||||||
await ref.read(sourcedTrackProvider(intendedActiveTrack).future);
|
await ref.read(sourcedTrackProvider(intendedActiveTrack).future);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +294,7 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
|
|||||||
await removeCollections(state.collections);
|
await removeCollections(state.collections);
|
||||||
|
|
||||||
await audioPlayer.openPlaylist(
|
await audioPlayer.openPlaylist(
|
||||||
medias,
|
medias.map((s) => s as Media).toList(),
|
||||||
initialIndex: initialIndex,
|
initialIndex: initialIndex,
|
||||||
autoPlay: autoPlay,
|
autoPlay: autoPlay,
|
||||||
);
|
);
|
||||||
|
@ -41,9 +41,16 @@ class SpotubeMedia extends mk.Media {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get uri => track is LocalTrack
|
String get uri {
|
||||||
? (track as LocalTrack).path
|
return switch (track) {
|
||||||
: "http://${kIsWindows ? "localhost" : InternetAddress.anyIPv4.address}:$serverPort/stream/${track.id}";
|
/// [super.uri] must be used instead of [track.path] to prevent wrong
|
||||||
|
/// path format exceptions in Windows causing [extras] to be null
|
||||||
|
LocalTrack() => super.uri,
|
||||||
|
_ =>
|
||||||
|
"http://${kIsWindows ? "localhost" : InternetAddress.anyIPv4.address}:"
|
||||||
|
"$serverPort/stream/${track.id}",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
factory SpotubeMedia.fromMedia(mk.Media media) {
|
factory SpotubeMedia.fromMedia(mk.Media media) {
|
||||||
final track = media.uri.startsWith("http")
|
final track = media.uri.startsWith("http")
|
||||||
@ -56,20 +63,20 @@ class SpotubeMedia extends mk.Media {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
// @override
|
||||||
operator ==(Object other) {
|
// operator ==(Object other) {
|
||||||
if (other is! SpotubeMedia) return false;
|
// if (other is! SpotubeMedia) return false;
|
||||||
|
|
||||||
final isLocal = track is LocalTrack && other.track is LocalTrack;
|
// final isLocal = track is LocalTrack && other.track is LocalTrack;
|
||||||
return isLocal
|
// return isLocal
|
||||||
? (other.track as LocalTrack).path == (track as LocalTrack).path
|
// ? (other.track as LocalTrack).path == (track as LocalTrack).path
|
||||||
: other.track.id == track.id;
|
// : other.track.id == track.id;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
// @override
|
||||||
int get hashCode => track is LocalTrack
|
// int get hashCode => track is LocalTrack
|
||||||
? (track as LocalTrack).path.hashCode
|
// ? (track as LocalTrack).path.hashCode
|
||||||
: track.id.hashCode;
|
// : track.id.hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class AudioPlayerInterface {
|
abstract class AudioPlayerInterface {
|
||||||
|
@ -149,5 +149,8 @@ mixin SpotubeAudioPlayersStreams on AudioPlayerInterface {
|
|||||||
|
|
||||||
Stream<String> get errorStream => _mkPlayer.stream.error;
|
Stream<String> get errorStream => _mkPlayer.stream.error;
|
||||||
|
|
||||||
Stream<mk.Playlist> get playlistStream => _mkPlayer.stream.playlist;
|
Stream<mk.Playlist> get playlistStream => _mkPlayer.stream.playlist.map((s){
|
||||||
|
print("[Stream Playlist]: $s");
|
||||||
|
return s;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include <screen_retriever/screen_retriever_plugin.h>
|
#include <screen_retriever/screen_retriever_plugin.h>
|
||||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||||
#include <system_theme/system_theme_plugin.h>
|
#include <system_theme/system_theme_plugin.h>
|
||||||
#include <system_tray/system_tray_plugin.h>
|
|
||||||
#include <tray_manager/tray_manager_plugin.h>
|
#include <tray_manager/tray_manager_plugin.h>
|
||||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
#include <window_manager/window_manager_plugin.h>
|
#include <window_manager/window_manager_plugin.h>
|
||||||
@ -48,9 +47,6 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
|||||||
g_autoptr(FlPluginRegistrar) system_theme_registrar =
|
g_autoptr(FlPluginRegistrar) system_theme_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "SystemThemePlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "SystemThemePlugin");
|
||||||
system_theme_plugin_register_with_registrar(system_theme_registrar);
|
system_theme_plugin_register_with_registrar(system_theme_registrar);
|
||||||
g_autoptr(FlPluginRegistrar) system_tray_registrar =
|
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "SystemTrayPlugin");
|
|
||||||
system_tray_plugin_register_with_registrar(system_tray_registrar);
|
|
||||||
g_autoptr(FlPluginRegistrar) tray_manager_registrar =
|
g_autoptr(FlPluginRegistrar) tray_manager_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin");
|
||||||
tray_manager_plugin_register_with_registrar(tray_manager_registrar);
|
tray_manager_plugin_register_with_registrar(tray_manager_registrar);
|
||||||
|
@ -12,7 +12,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
screen_retriever
|
screen_retriever
|
||||||
sqlite3_flutter_libs
|
sqlite3_flutter_libs
|
||||||
system_theme
|
system_theme
|
||||||
system_tray
|
|
||||||
tray_manager
|
tray_manager
|
||||||
url_launcher_linux
|
url_launcher_linux
|
||||||
window_manager
|
window_manager
|
||||||
|
@ -23,7 +23,6 @@ import shared_preferences_foundation
|
|||||||
import sqflite
|
import sqflite
|
||||||
import sqlite3_flutter_libs
|
import sqlite3_flutter_libs
|
||||||
import system_theme
|
import system_theme
|
||||||
import system_tray
|
|
||||||
import tray_manager
|
import tray_manager
|
||||||
import url_launcher_macos
|
import url_launcher_macos
|
||||||
import window_manager
|
import window_manager
|
||||||
@ -47,7 +46,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||||
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
||||||
SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin"))
|
SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin"))
|
||||||
SystemTrayPlugin.register(with: registry.registrar(forPlugin: "SystemTrayPlugin"))
|
|
||||||
TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))
|
TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))
|
||||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||||
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
|
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
|
||||||
|
15
pubspec.lock
15
pubspec.lock
@ -717,7 +717,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "packages/flutter_discord_rpc"
|
path: "packages/flutter_discord_rpc"
|
||||||
ref: cargokit
|
ref: cargokit
|
||||||
resolved-ref: "7ca0bbb786d8ce0e4bf8341b673b6c709ba69146"
|
resolved-ref: ed8d0d67fae7a23acc9b58c84f01d02abd8d8515
|
||||||
url: "https://github.com/KRTirtho/frb_plugins.git"
|
url: "https://github.com/KRTirtho/frb_plugins.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0+1"
|
version: "0.1.0+1"
|
||||||
@ -1484,7 +1484,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "packages/metadata_god"
|
path: "packages/metadata_god"
|
||||||
ref: cargokit
|
ref: cargokit
|
||||||
resolved-ref: "7ca0bbb786d8ce0e4bf8341b673b6c709ba69146"
|
resolved-ref: ed8d0d67fae7a23acc9b58c84f01d02abd8d8515
|
||||||
url: "https://github.com/KRTirtho/frb_plugins.git"
|
url: "https://github.com/KRTirtho/frb_plugins.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.5.3"
|
version: "0.5.3"
|
||||||
@ -1987,7 +1987,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "packages/smtc_windows"
|
path: "packages/smtc_windows"
|
||||||
ref: cargokit
|
ref: cargokit
|
||||||
resolved-ref: "7ca0bbb786d8ce0e4bf8341b673b6c709ba69146"
|
resolved-ref: ed8d0d67fae7a23acc9b58c84f01d02abd8d8515
|
||||||
url: "https://github.com/KRTirtho/frb_plugins.git"
|
url: "https://github.com/KRTirtho/frb_plugins.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.3"
|
version: "0.1.3"
|
||||||
@ -2151,15 +2151,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.0.2"
|
version: "0.0.2"
|
||||||
system_tray:
|
|
||||||
dependency: "direct overridden"
|
|
||||||
description:
|
|
||||||
path: "."
|
|
||||||
ref: dc7ef410d5cfec897edf060c1c4baff69f7c181c
|
|
||||||
resolved-ref: dc7ef410d5cfec897edf060c1c4baff69f7c181c
|
|
||||||
url: "https://github.com/antler119/system_tray"
|
|
||||||
source: git
|
|
||||||
version: "2.0.2"
|
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
11
pubspec.yaml
11
pubspec.yaml
@ -164,17 +164,6 @@ dev_dependencies:
|
|||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
uuid: ^4.4.0
|
uuid: ^4.4.0
|
||||||
system_tray:
|
|
||||||
# TODO: remove this when flutter_desktop_tools gets updated
|
|
||||||
# to use [MenuItemBase] instead of [MenuItem]
|
|
||||||
git:
|
|
||||||
url: https://github.com/antler119/system_tray
|
|
||||||
ref: dc7ef410d5cfec897edf060c1c4baff69f7c181c
|
|
||||||
# media_kit_native_event_loop: # to fix "macro name must be an identifier"
|
|
||||||
# git:
|
|
||||||
# url: https://github.com/media-kit/media-kit
|
|
||||||
# path: media_kit_native_event_loop
|
|
||||||
# ref: main
|
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
generate: true
|
generate: true
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include <screen_retriever/screen_retriever_plugin.h>
|
#include <screen_retriever/screen_retriever_plugin.h>
|
||||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||||
#include <system_theme/system_theme_plugin.h>
|
#include <system_theme/system_theme_plugin.h>
|
||||||
#include <system_tray/system_tray_plugin.h>
|
|
||||||
#include <tray_manager/tray_manager_plugin.h>
|
#include <tray_manager/tray_manager_plugin.h>
|
||||||
#include <url_launcher_windows/url_launcher_windows.h>
|
#include <url_launcher_windows/url_launcher_windows.h>
|
||||||
#include <window_manager/window_manager_plugin.h>
|
#include <window_manager/window_manager_plugin.h>
|
||||||
@ -45,8 +44,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
|||||||
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
|
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
|
||||||
SystemThemePluginRegisterWithRegistrar(
|
SystemThemePluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("SystemThemePlugin"));
|
registry->GetRegistrarForPlugin("SystemThemePlugin"));
|
||||||
SystemTrayPluginRegisterWithRegistrar(
|
|
||||||
registry->GetRegistrarForPlugin("SystemTrayPlugin"));
|
|
||||||
TrayManagerPluginRegisterWithRegistrar(
|
TrayManagerPluginRegisterWithRegistrar(
|
||||||
registry->GetRegistrarForPlugin("TrayManagerPlugin"));
|
registry->GetRegistrarForPlugin("TrayManagerPlugin"));
|
||||||
UrlLauncherWindowsRegisterWithRegistrar(
|
UrlLauncherWindowsRegisterWithRegistrar(
|
||||||
|
@ -14,7 +14,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
screen_retriever
|
screen_retriever
|
||||||
sqlite3_flutter_libs
|
sqlite3_flutter_libs
|
||||||
system_theme
|
system_theme
|
||||||
system_tray
|
|
||||||
tray_manager
|
tray_manager
|
||||||
url_launcher_windows
|
url_launcher_windows
|
||||||
window_manager
|
window_manager
|
||||||
|
Loading…
Reference in New Issue
Block a user