mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
feat: add web support although nothing works just as expected
This commit is contained in:
parent
d6687603d1
commit
2818ed5c9d
@ -90,8 +90,7 @@ class Home extends HookConsumerWidget {
|
|||||||
child: MoveWindow(),
|
child: MoveWindow(),
|
||||||
),
|
),
|
||||||
Expanded(child: MoveWindow()),
|
Expanded(child: MoveWindow()),
|
||||||
if (!Platform.isMacOS && !kIsMobile)
|
if (!kIsMacOS && !kIsMobile) const TitleBarActionButtons(),
|
||||||
const TitleBarActionButtons(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:spotify/spotify.dart';
|
import 'package:spotify/spotify.dart';
|
||||||
@ -54,9 +55,10 @@ class PlayerActions extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
DownloadTrackButton(
|
if (!kIsWeb)
|
||||||
track: playback.track,
|
DownloadTrackButton(
|
||||||
),
|
track: playback.track,
|
||||||
|
),
|
||||||
if (auth.isLoggedIn)
|
if (auth.isLoggedIn)
|
||||||
FutureBuilder<bool>(
|
FutureBuilder<bool>(
|
||||||
future: playback.track?.id != null
|
future: playback.track?.id != null
|
||||||
|
@ -110,13 +110,13 @@ class PageWindowTitleBar extends StatelessWidget
|
|||||||
color: backgroundColor,
|
color: backgroundColor,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
if (Platform.isMacOS)
|
if (kIsMacOS)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width * 0.045,
|
width: MediaQuery.of(context).size.width * 0.045,
|
||||||
),
|
),
|
||||||
if (leading != null) leading!,
|
if (leading != null) leading!,
|
||||||
Expanded(child: MoveWindow(child: Center(child: center))),
|
Expanded(child: MoveWindow(child: Center(child: center))),
|
||||||
if (!Platform.isMacOS && !kIsMobile)
|
if (!kIsMacOS && !kIsMobile)
|
||||||
TitleBarActionButtons(color: foregroundColor)
|
TitleBarActionButtons(color: foregroundColor)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -46,7 +46,7 @@ void main() async {
|
|||||||
}
|
}
|
||||||
appWindow.show();
|
appWindow.show();
|
||||||
});
|
});
|
||||||
} else {
|
} else if (kIsMobile) {
|
||||||
await FlutterDownloader.initialize(
|
await FlutterDownloader.initialize(
|
||||||
debug: kDebugMode,
|
debug: kDebugMode,
|
||||||
ignoreSsl: true,
|
ignoreSsl: true,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
@ -31,7 +32,7 @@ class _SpotubeLogger extends Logger {
|
|||||||
class _SpotubeLogFilter extends DevelopmentFilter {
|
class _SpotubeLogFilter extends DevelopmentFilter {
|
||||||
@override
|
@override
|
||||||
bool shouldLog(LogEvent event) {
|
bool shouldLog(LogEvent event) {
|
||||||
final env = Platform.environment;
|
final env = kIsWeb ? {} : Platform.environment;
|
||||||
if ((env["DEBUG"] == "true" && event.level == Level.debug) ||
|
if ((env["DEBUG"] == "true" && event.level == Level.debug) ||
|
||||||
(env["VERBOSE"] == "true" && event.level == Level.verbose) ||
|
(env["VERBOSE"] == "true" && event.level == Level.verbose) ||
|
||||||
(env["ERROR"] == "true" && event.level == Level.error)) {
|
(env["ERROR"] == "true" && event.level == Level.error)) {
|
||||||
|
@ -2,11 +2,13 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:dbus/dbus.dart';
|
import 'package:dbus/dbus.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:spotube/utils/platform.dart';
|
||||||
|
|
||||||
final Provider<DBusClient?> dbusClientProvider = Provider<DBusClient?>((ref) {
|
final Provider<DBusClient?> dbusClientProvider = Provider<DBusClient?>((ref) {
|
||||||
if (Platform.isLinux) {
|
if (kIsLinux) {
|
||||||
return DBusClient.session();
|
return DBusClient.session();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
final dbus = DBusClient.session();
|
final dbus = DBusClient.session();
|
||||||
|
@ -18,6 +18,7 @@ import 'package:spotube/provider/YouTube.dart';
|
|||||||
import 'package:spotube/services/LinuxAudioService.dart';
|
import 'package:spotube/services/LinuxAudioService.dart';
|
||||||
import 'package:spotube/services/MobileAudioService.dart';
|
import 'package:spotube/services/MobileAudioService.dart';
|
||||||
import 'package:spotube/utils/PersistedChangeNotifier.dart';
|
import 'package:spotube/utils/PersistedChangeNotifier.dart';
|
||||||
|
import 'package:spotube/utils/platform.dart';
|
||||||
import 'package:spotube/utils/primitive_utils.dart';
|
import 'package:spotube/utils/primitive_utils.dart';
|
||||||
import 'package:spotube/utils/service_utils.dart';
|
import 'package:spotube/utils/service_utils.dart';
|
||||||
import 'package:spotube/utils/type_conversion_utils.dart';
|
import 'package:spotube/utils/type_conversion_utils.dart';
|
||||||
@ -79,14 +80,14 @@ class Playback extends PersistedChangeNotifier {
|
|||||||
_subscriptions = [],
|
_subscriptions = [],
|
||||||
status = PlaybackStatus.idle,
|
status = PlaybackStatus.idle,
|
||||||
super() {
|
super() {
|
||||||
if (Platform.isLinux) {
|
if (kIsLinux) {
|
||||||
_linuxAudioService = LinuxAudioService(this);
|
_linuxAudioService = LinuxAudioService(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
(() async {
|
(() async {
|
||||||
cache = await Hive.openLazyBox<CacheTrack>("track-cache");
|
cache = await Hive.openLazyBox<CacheTrack>("track-cache");
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (kIsAndroid) {
|
||||||
await player.setVolume(1);
|
await player.setVolume(1);
|
||||||
volume = 1;
|
volume = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -433,9 +434,9 @@ class Playback extends PersistedChangeNotifier {
|
|||||||
|
|
||||||
final audioManifest = trackManifest.audioOnly.where((info) {
|
final audioManifest = trackManifest.audioOnly.where((info) {
|
||||||
final isMp4a = info.codec.mimeType == "audio/mp4";
|
final isMp4a = info.codec.mimeType == "audio/mp4";
|
||||||
if (Platform.isLinux) {
|
if (kIsLinux) {
|
||||||
return !isMp4a;
|
return !isMp4a;
|
||||||
} else if (Platform.isMacOS || Platform.isIOS) {
|
} else if (kIsMacOS || kIsIOS) {
|
||||||
return isMp4a;
|
return isMp4a;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -10,6 +10,7 @@ import 'package:spotube/models/generated_secrets.dart';
|
|||||||
import 'package:spotube/provider/Playback.dart';
|
import 'package:spotube/provider/Playback.dart';
|
||||||
import 'package:spotube/utils/PersistedChangeNotifier.dart';
|
import 'package:spotube/utils/PersistedChangeNotifier.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:spotube/utils/platform.dart';
|
||||||
import 'package:spotube/utils/primitive_utils.dart';
|
import 'package:spotube/utils/primitive_utils.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
@ -126,7 +127,7 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String> _getDefaultDownloadDirectory() async {
|
Future<String> _getDefaultDownloadDirectory() async {
|
||||||
if (Platform.isAndroid) return "/storage/emulated/0/Download/Spotube";
|
if (kIsAndroid) return "/storage/emulated/0/Download/Spotube";
|
||||||
return getDownloadsDirectory().then((dir) {
|
return getDownloadsDirectory().then((dir) {
|
||||||
return path.join(dir!.path, "Spotube");
|
return path.join(dir!.path, "Spotube");
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
final kIsDesktop = Platform.isLinux || Platform.isWindows || Platform.isMacOS;
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
final kIsMobile = Platform.isAndroid || Platform.isIOS;
|
final kIsDesktop = kIsLinux || kIsWindows || kIsMacOS;
|
||||||
|
|
||||||
final kIsFlatpak = Platform.environment["FLATPAK_ID"] != null;
|
final kIsMobile = kIsAndroid || kIsIOS;
|
||||||
|
|
||||||
|
final kIsFlatpak = kIsWeb ? false : Platform.environment["FLATPAK_ID"] != null;
|
||||||
|
|
||||||
|
final kIsMacOS = kIsWeb ? false : Platform.isMacOS;
|
||||||
|
final kIsLinux = kIsWeb ? false : Platform.isLinux;
|
||||||
|
final kIsAndroid = kIsWeb ? false : Platform.isAndroid;
|
||||||
|
final kIsIOS = kIsWeb ? false : Platform.isIOS;
|
||||||
|
final kIsWindows = kIsWeb ? false : Platform.isWindows;
|
||||||
|
Loading…
Reference in New Issue
Block a user