Skip to content

Commit

Permalink
chore: fix windows playback not working for loop back ipv4
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Jul 5, 2024
1 parent 7dd76d2 commit 359b918
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 4 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,16 @@ import 'package:timezone/data/latest.dart' as tz;
import 'package:window_manager/window_manager.dart';

Future<void> main(List<String> 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();
Expand Down
5 changes: 3 additions & 2 deletions lib/services/audio_player/audio_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand All @@ -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")
Expand Down

0 comments on commit 359b918

Please sign in to comment.