mirror of
https://github.com/immich-app/immich.git
synced 2025-06-23 15:30:51 -04:00
* initial cast framework complete and mocked cast dialog working * wip casting * casting works! just need to add session key check and remote video controls * cleanup of classes * add session expiration checks * cast dialog now shows connected device at top of list with a list header. Discovered devices are also cached for app session. * cast video player finalized * show fullsize assets on casting * translation already happens on the text element * remove prints * fix lintings * code review changes from @shenlong-tanwen * fix connect method override * fix alphabetization * remove important * filter chromecast audio devices * fix some disconnect command ordering issues and unawaited futures * remove prints * only disconnect if we are connected * don't try to reconnect if its the current device * add cast button to top bar * format sessions api * more formatting issues fixed * add snack bar to tell user that we cannot cast an asset that is not uploaded to server * make casting icon change to primary color when casting is active * only show casting snackbar if we are casting * dont show cast button if asset is remote and we are not casting * stop playing media if we seek to an asset that is not remote * remove https check since it works with local http IP addresses * remove unneeded imports * fix recasting when socket closes * fix info plist formatting * only show cast button if there is an active websocket connection (ie the server is accessible) * add device capability bitmask checks * small comment about bitmask
89 lines
2.4 KiB
Dart
89 lines
2.4 KiB
Dart
import 'dart:convert';
|
|
|
|
enum CastDestinationType { googleCast }
|
|
|
|
enum CastState { idle, playing, paused, buffering }
|
|
|
|
class CastManagerState {
|
|
final bool isCasting;
|
|
final String receiverName;
|
|
final CastState castState;
|
|
final Duration currentTime;
|
|
final Duration duration;
|
|
|
|
const CastManagerState({
|
|
required this.isCasting,
|
|
required this.receiverName,
|
|
required this.castState,
|
|
required this.currentTime,
|
|
required this.duration,
|
|
});
|
|
|
|
CastManagerState copyWith({
|
|
bool? isCasting,
|
|
String? receiverName,
|
|
CastState? castState,
|
|
Duration? currentTime,
|
|
Duration? duration,
|
|
}) {
|
|
return CastManagerState(
|
|
isCasting: isCasting ?? this.isCasting,
|
|
receiverName: receiverName ?? this.receiverName,
|
|
castState: castState ?? this.castState,
|
|
currentTime: currentTime ?? this.currentTime,
|
|
duration: duration ?? this.duration,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toMap() {
|
|
final result = <String, dynamic>{};
|
|
|
|
result.addAll({'isCasting': isCasting});
|
|
result.addAll({'receiverName': receiverName});
|
|
result.addAll({'castState': castState});
|
|
result.addAll({'currentTime': currentTime.inSeconds});
|
|
result.addAll({'duration': duration.inSeconds});
|
|
|
|
return result;
|
|
}
|
|
|
|
factory CastManagerState.fromMap(Map<String, dynamic> map) {
|
|
return CastManagerState(
|
|
isCasting: map['isCasting'] ?? false,
|
|
receiverName: map['receiverName'] ?? '',
|
|
castState: map['castState'] ?? CastState.idle,
|
|
currentTime: Duration(seconds: map['currentTime']?.toInt() ?? 0),
|
|
duration: Duration(seconds: map['duration']?.toInt() ?? 0),
|
|
);
|
|
}
|
|
|
|
String toJson() => json.encode(toMap());
|
|
|
|
factory CastManagerState.fromJson(String source) =>
|
|
CastManagerState.fromMap(json.decode(source));
|
|
|
|
@override
|
|
String toString() =>
|
|
'CastManagerState(isCasting: $isCasting, receiverName: $receiverName, castState: $castState, currentTime: $currentTime, duration: $duration)';
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (identical(this, other)) return true;
|
|
|
|
return other is CastManagerState &&
|
|
other.isCasting == isCasting &&
|
|
other.receiverName == receiverName &&
|
|
other.castState == castState &&
|
|
other.currentTime == currentTime &&
|
|
other.duration == duration;
|
|
}
|
|
|
|
@override
|
|
int get hashCode =>
|
|
isCasting.hashCode ^
|
|
receiverName.hashCode ^
|
|
castState.hashCode ^
|
|
currentTime.hashCode ^
|
|
duration.hashCode;
|
|
}
|