spotube/lib/services/device_info/device_info.dart
Kingkor Roy Tirtho 68374efd3e
feat: LAN connect a.k.a control remote Spotube playback and local output device selection (#1355)
* feat: add connect server support

* feat: add ability discover and connect to same network Spotube(s) and sync queue

* feat(connect): add player controls, shuffle, loop, progress bar and queue support

* feat: make control page adaptive

* feat: add volume control support

* cd: upgrade macos runner version

* chore: upgrade inappwebview version to 6

* feat: customized devices button

* feat: add user icon next to devices button

* feat: add play in remote device support

* feat: show alert when new client connects

* fix: ignore the device itself from broadcast list

* fix: volume control not working

* feat: add ability to select current device's output speaker
2024-04-04 22:22:00 +06:00

35 lines
1002 B
Dart

import 'package:device_info_plus/device_info_plus.dart';
class DeviceInfoService {
final DeviceInfoPlugin deviceInfo;
DeviceInfoService._() : deviceInfo = DeviceInfoPlugin();
static final instance = DeviceInfoService._();
Future<String> deviceId() async {
final info = await deviceInfo.deviceInfo;
return switch (info) {
AndroidDeviceInfo() => info.id,
IosDeviceInfo() => info.identifierForVendor ?? info.model,
MacOsDeviceInfo() => info.systemGUID ?? info.model,
WindowsDeviceInfo() => info.deviceId,
LinuxDeviceInfo() => info.machineId ?? info.id,
_ => 'Unknown',
};
}
Future<String> computerName() async {
final info = await deviceInfo.deviceInfo;
return switch (info) {
AndroidDeviceInfo() => info.model,
IosDeviceInfo() => info.localizedModel,
MacOsDeviceInfo() => info.computerName,
WindowsDeviceInfo() => info.computerName,
LinuxDeviceInfo() => info.name,
_ => 'Unknown',
};
}
}