Skip to content

Commit

Permalink
Upgrade dependencies (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa authored Feb 11, 2024
2 parents 4b7e083 + 0801f39 commit b4d8c6d
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 100 deletions.
14 changes: 2 additions & 12 deletions lib/widgets/device_grid/video_status_label.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,12 @@ class _VideoStatusLabelState extends State<VideoStatusLabel> {
final overlayKey = GlobalKey(debugLabel: 'Label Overlay');

bool get isLoading => widget.video.lastImageUpdate == null;
String get _source => widget.video.player.dataSource!;
bool get isLive =>
widget.video.player.dataSource != null &&
// It is only LIVE if it starts with rtsp or is hls
(_source.startsWith('rtsp') ||
_source.contains('media/mjpeg') ||
_source.contains('.m3u8') /* hls */);

VideoLabel get status => widget.video.error != null
? VideoLabel.error
: isLoading
? VideoLabel.loading
: !isLive
: !widget.video.player.isLive
? VideoLabel.recorded
: widget.video.player.isImageOld
? VideoLabel.timedOut
Expand All @@ -105,7 +98,6 @@ class _VideoStatusLabelState extends State<VideoStatusLabel> {
device: widget.device,
video: widget.video,
label: status,
isLive: isLive,
event: widget.event,
);
final minHeight = label.buildTextSpans(context).length * 15;
Expand Down Expand Up @@ -248,15 +240,13 @@ class _DeviceVideoInfo extends StatelessWidget {
final Device device;
final VideoViewInheritance video;
final VideoLabel label;
final bool isLive;

final Event? event;

const _DeviceVideoInfo({
required this.device,
required this.video,
required this.label,
required this.isLive,
required this.event,
});

Expand All @@ -271,7 +261,7 @@ class _DeviceVideoInfo extends StatelessWidget {
title: loc.server,
data: '${device.server.name} (${device.id})',
);
if (isLive) {
if (video.player.isLive) {
return [
name,
server,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,21 @@ abstract class UnityVideoPlayer with ChangeNotifier {
/// The video is considered late if the current position is more than 1.5
/// seconds after the last image update.
bool get isLate {
if (lastImageUpdate == null) return false;
if (dataSource == null || lastImageUpdate == null || !isLive) return false;
final now = DateTime.now();
final diff = now.difference(lastImageUpdate!);
return diff.inMilliseconds > 1500;
}

/// Whether the video is a live stream.
bool get isLive =>
// TODO(bdlukaa): do a better checking of this
dataSource != null &&
// It is only LIVE if it starts with rtsp or is hls
(dataSource!.startsWith('rtsp') ||
dataSource!.contains('media/mjpeg') ||
dataSource!.contains('.m3u8') /* hls */);

void _handleLateVideo() {
switch (lateVideoBehavior) {
case LateVideoBehavior.automatic:
Expand Down
Loading

0 comments on commit b4d8c6d

Please sign in to comment.