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(),
|
||||
),
|
||||
Expanded(child: MoveWindow()),
|
||||
if (!Platform.isMacOS && !kIsMobile)
|
||||
const TitleBarActionButtons(),
|
||||
if (!kIsMacOS && !kIsMobile) const TitleBarActionButtons(),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
@ -54,6 +55,7 @@ class PlayerActions extends HookConsumerWidget {
|
||||
}
|
||||
: null,
|
||||
),
|
||||
if (!kIsWeb)
|
||||
DownloadTrackButton(
|
||||
track: playback.track,
|
||||
),
|
||||
|
@ -110,13 +110,13 @@ class PageWindowTitleBar extends StatelessWidget
|
||||
color: backgroundColor,
|
||||
child: Row(
|
||||
children: [
|
||||
if (Platform.isMacOS)
|
||||
if (kIsMacOS)
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.045,
|
||||
),
|
||||
if (leading != null) leading!,
|
||||
Expanded(child: MoveWindow(child: Center(child: center))),
|
||||
if (!Platform.isMacOS && !kIsMobile)
|
||||
if (!kIsMacOS && !kIsMobile)
|
||||
TitleBarActionButtons(color: foregroundColor)
|
||||
],
|
||||
),
|
||||
|
@ -46,7 +46,7 @@ void main() async {
|
||||
}
|
||||
appWindow.show();
|
||||
});
|
||||
} else {
|
||||
} else if (kIsMobile) {
|
||||
await FlutterDownloader.initialize(
|
||||
debug: kDebugMode,
|
||||
ignoreSsl: true,
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
@ -31,7 +32,7 @@ class _SpotubeLogger extends Logger {
|
||||
class _SpotubeLogFilter extends DevelopmentFilter {
|
||||
@override
|
||||
bool shouldLog(LogEvent event) {
|
||||
final env = Platform.environment;
|
||||
final env = kIsWeb ? {} : Platform.environment;
|
||||
if ((env["DEBUG"] == "true" && event.level == Level.debug) ||
|
||||
(env["VERBOSE"] == "true" && event.level == Level.verbose) ||
|
||||
(env["ERROR"] == "true" && event.level == Level.error)) {
|
||||
|
@ -2,11 +2,13 @@ import 'dart:io';
|
||||
|
||||
import 'package:dbus/dbus.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:spotube/utils/platform.dart';
|
||||
|
||||
final Provider<DBusClient?> dbusClientProvider = Provider<DBusClient?>((ref) {
|
||||
if (Platform.isLinux) {
|
||||
if (kIsLinux) {
|
||||
return DBusClient.session();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
final dbus = DBusClient.session();
|
||||
|
@ -18,6 +18,7 @@ import 'package:spotube/provider/YouTube.dart';
|
||||
import 'package:spotube/services/LinuxAudioService.dart';
|
||||
import 'package:spotube/services/MobileAudioService.dart';
|
||||
import 'package:spotube/utils/PersistedChangeNotifier.dart';
|
||||
import 'package:spotube/utils/platform.dart';
|
||||
import 'package:spotube/utils/primitive_utils.dart';
|
||||
import 'package:spotube/utils/service_utils.dart';
|
||||
import 'package:spotube/utils/type_conversion_utils.dart';
|
||||
@ -79,14 +80,14 @@ class Playback extends PersistedChangeNotifier {
|
||||
_subscriptions = [],
|
||||
status = PlaybackStatus.idle,
|
||||
super() {
|
||||
if (Platform.isLinux) {
|
||||
if (kIsLinux) {
|
||||
_linuxAudioService = LinuxAudioService(this);
|
||||
}
|
||||
|
||||
(() async {
|
||||
cache = await Hive.openLazyBox<CacheTrack>("track-cache");
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
if (kIsAndroid) {
|
||||
await player.setVolume(1);
|
||||
volume = 1;
|
||||
} else {
|
||||
@ -433,9 +434,9 @@ class Playback extends PersistedChangeNotifier {
|
||||
|
||||
final audioManifest = trackManifest.audioOnly.where((info) {
|
||||
final isMp4a = info.codec.mimeType == "audio/mp4";
|
||||
if (Platform.isLinux) {
|
||||
if (kIsLinux) {
|
||||
return !isMp4a;
|
||||
} else if (Platform.isMacOS || Platform.isIOS) {
|
||||
} else if (kIsMacOS || kIsIOS) {
|
||||
return isMp4a;
|
||||
} else {
|
||||
return true;
|
||||
|
@ -10,6 +10,7 @@ import 'package:spotube/models/generated_secrets.dart';
|
||||
import 'package:spotube/provider/Playback.dart';
|
||||
import 'package:spotube/utils/PersistedChangeNotifier.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:spotube/utils/platform.dart';
|
||||
import 'package:spotube/utils/primitive_utils.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
@ -126,7 +127,7 @@ class UserPreferences extends PersistedChangeNotifier {
|
||||
}
|
||||
|
||||
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 path.join(dir!.path, "Spotube");
|
||||
});
|
||||
|
@ -1,7 +1,15 @@
|
||||
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