From 359b918e6bb0a2c4792492b8cc84761af1c8aea4 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Fri, 5 Jul 2024 15:32:18 +0600 Subject: [PATCH] chore: fix windows playback not working for loop back ipv4 --- lib/main.dart | 10 ++++------ lib/services/audio_player/audio_player.dart | 5 +++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index db7773f9e..45f4462d7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -47,18 +47,16 @@ import 'package:timezone/data/latest.dart' as tz; import 'package:window_manager/window_manager.dart'; Future main(List rawArgs) async { - WidgetsFlutterBinding.ensureInitialized(); - - if (runWebViewTitleBarWidget(rawArgs)) { - return; - } - final arguments = await startCLI(rawArgs); AppLogger.initialize(arguments["verbose"]); AppLogger.runZoned(() async { final widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); + if (runWebViewTitleBarWidget(rawArgs)) { + return; + } + await registerWindowsScheme("spotify"); tz.initializeTimeZones(); diff --git a/lib/services/audio_player/audio_player.dart b/lib/services/audio_player/audio_player.dart index bb1a62036..7915dc3bd 100644 --- a/lib/services/audio_player/audio_player.dart +++ b/lib/services/audio_player/audio_player.dart @@ -12,6 +12,7 @@ import 'package:media_kit/media_kit.dart' as mk; import 'package:spotube/services/audio_player/playback_state.dart'; import 'package:spotube/services/sourced_track/sourced_track.dart'; +import 'package:spotube/utils/platform.dart'; part 'audio_players_streams_mixin.dart'; part 'audio_player_impl.dart'; @@ -28,7 +29,7 @@ class SpotubeMedia extends mk.Media { }) : super( track is LocalTrack ? track.path - : "http://${InternetAddress.anyIPv4.address}:$serverPort/stream/${track.id}", + : "http://${kIsWindows ? "localhost" : InternetAddress.anyIPv4.address}:$serverPort/stream/${track.id}", extras: { ...?extras, "track": switch (track) { @@ -42,7 +43,7 @@ class SpotubeMedia extends mk.Media { @override String get uri => track is LocalTrack ? (track as LocalTrack).path - : "http://${InternetAddress.anyIPv4.address}:$serverPort/stream/${track.id}"; + : "http://${kIsWindows ? "localhost" : InternetAddress.anyIPv4.address}:$serverPort/stream/${track.id}"; factory SpotubeMedia.fromMedia(mk.Media media) { final track = media.uri.startsWith("http")