diff --git a/lib/widgets/device_grid/video_status_label.dart b/lib/widgets/device_grid/video_status_label.dart index 524c0f0d..96de7404 100644 --- a/lib/widgets/device_grid/video_status_label.dart +++ b/lib/widgets/device_grid/video_status_label.dart @@ -57,10 +57,10 @@ class _VideoStatusLabelState extends State { String get _source => widget.video.player.dataSource!; bool get isLive => widget.video.player.dataSource != null && - // It is only LIVE if it starts with rtsp and isn't hsl + // It is only LIVE if it starts with rtsp or is hsl (_source.startsWith('rtsp') || _source.contains('media/mjpeg.php') || - _source.endsWith('index.m3u8')); + _source.endsWith('index.m3u8') /* hsl */); _VideoLabel get status => widget.video.error != null ? _VideoLabel.error @@ -213,14 +213,17 @@ class _DeviceVideoInfo extends StatelessWidget { List buildTextSpans(BuildContext context) { final loc = AppLocalizations.of(context); + + final name = _buildTextSpan(context, title: loc.device, data: device.name); + final server = _buildTextSpan( + context, + title: loc.server, + data: '${device.server.name} (${device.id})', + ); if (isLive) { return [ - _buildTextSpan(context, title: loc.device, data: device.name), - _buildTextSpan( - context, - title: loc.server, - data: '${device.server.name} (${device.id})', - ), + name, + server, _buildTextSpan( context, title: loc.ptzSupported, @@ -241,16 +244,11 @@ class _DeviceVideoInfo extends StatelessWidget { last: true, ), ]; - } else { + } else if (event != null) { // If not live, it is a recorded footage - assert(event != null); return [ - _buildTextSpan(context, title: loc.device, data: device.name), - _buildTextSpan( - context, - title: loc.server, - data: '${device.server.name} (${device.id})', - ), + name, + server, _buildTextSpan( context, title: loc.duration, @@ -268,6 +266,8 @@ class _DeviceVideoInfo extends StatelessWidget { last: true, ), ]; + } else { + return [name, server]; } } diff --git a/lib/widgets/error_warning.dart b/lib/widgets/error_warning.dart index d4fae764..3618edcd 100644 --- a/lib/widgets/error_warning.dart +++ b/lib/widgets/error_warning.dart @@ -40,6 +40,7 @@ class ErrorWarning extends StatelessWidget { const SizedBox(height: 8.0), Text( message.toUpperCase(), + textAlign: TextAlign.center, style: const TextStyle( color: Colors.white70, fontSize: 12.0, diff --git a/packages/unity_video_player/unity_video_player_platform_interface/lib/unity_video_player_platform_interface.dart b/packages/unity_video_player/unity_video_player_platform_interface/lib/unity_video_player_platform_interface.dart index ba784475..04eaee6b 100644 --- a/packages/unity_video_player/unity_video_player_platform_interface/lib/unity_video_player_platform_interface.dart +++ b/packages/unity_video_player/unity_video_player_platform_interface/lib/unity_video_player_platform_interface.dart @@ -348,15 +348,17 @@ abstract class UnityVideoPlayer { } void _onDurationUpdate(Duration duration) { - _lastImageTime = DateTime.now(); - _isImageOld = false; - _oldImageTimer?.cancel(); - _oldImageTimer = Timer(timerInterval, () { - // If the image is still the same after the interval, then it's old. - if (duration <= duration) { - _isImageOld = true; - } - }); + if (duration > Duration.zero) { + _lastImageTime = DateTime.now(); + _isImageOld = false; + _oldImageTimer?.cancel(); + _oldImageTimer = Timer(timerInterval, () { + // If the image is still the same after the interval, then it's old. + if (duration <= duration) { + _isImageOld = true; + } + }); + } } /// The current data source url