minor fixes

This commit is contained in:
Thibault Deckers 2022-01-23 16:43:29 +09:00
parent a3bed14ee1
commit 2a4c07a657
4 changed files with 28 additions and 3 deletions

View file

@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file.
### Added
- Viewer: resize option when exporting
- Settings: export/import covers & favourites along with settings
- Portuguese translation (thanks Jonatas De Almeida Barros)
### Removed
@ -16,6 +18,8 @@ All notable changes to this project will be documented in this file.
- loading when system locale uses non-western arabic numerals
- handling timestamps provided in 10^-8 s (18 digits)
- Viewer: SVG export
- Viewer: sending to editing app on some environments
## <a id="v1.5.10"></a>[v1.5.10] - 2022-01-07

View file

@ -22,7 +22,8 @@ import 'package:fijkplayer/fijkplayer.dart';
import 'package:flutter/foundation.dart';
class VideoMetadataFormatter {
static final _anotherDatePattern = RegExp(r'(\d{4})[-/](\d{2})[-/](\d{2}) (\d{2}):(\d{2}):(\d{2})');
static final _dateY4M2D2H2m2s2Pattern = RegExp(r'(\d{4})[-/](\d{2})[-/](\d{2}) (\d{2}):(\d{2}):(\d{2})');
static final _dateY4M2D2H2m2s2APmPattern = RegExp(r'(\d{4})[-/](\d{2})[-/](\d{2})T(\d+):(\d+):(\d+) ([ap]m)Z');
static final _durationPattern = RegExp(r'(\d+):(\d+):(\d+)(.\d+)');
static final _locationPattern = RegExp(r'([+-][.0-9]+)');
static final Map<String, String> _codecNames = {
@ -115,9 +116,10 @@ class VideoMetadataFormatter {
// `DateTime` does not recognize these values found in the wild:
// - `UTC 2021-05-30 19:14:21`
// - `2021/10/31 21:23:17`
// - `2021-09-10T7:14:49 pmZ`
// - `2021` (not enough to build a date)
final match = _anotherDatePattern.firstMatch(dateString);
var match = _dateY4M2D2H2m2s2Pattern.firstMatch(dateString);
if (match != null) {
final year = int.tryParse(match.group(1)!);
final month = int.tryParse(match.group(2)!);
@ -132,6 +134,22 @@ class VideoMetadataFormatter {
}
}
match = _dateY4M2D2H2m2s2APmPattern.firstMatch(dateString);
if (match != null) {
final year = int.tryParse(match.group(1)!);
final month = int.tryParse(match.group(2)!);
final day = int.tryParse(match.group(3)!);
final hour = int.tryParse(match.group(4)!);
final minute = int.tryParse(match.group(5)!);
final second = int.tryParse(match.group(6)!);
final pm = match.group(7) == 'pm';
if (year != null && month != null && day != null && hour != null && minute != null && second != null) {
final date = DateTime(year, month, day, hour + (pm ? 12 : 0), minute, second, 0);
return date.millisecondsSinceEpoch;
}
}
return null;
}

View file

@ -183,7 +183,9 @@ class _EntryGoogleMapState extends State<EntryGoogleMap> with WidgetsBindingObse
_googleMapController = controller;
final zoom = await controller.getZoomLevel();
await _updateVisibleRegion(zoom: zoom, rotation: bounds.rotation);
if (mounted) {
setState(() {});
}
},
// compass disabled to use provider agnostic controls
compassEnabled: false,

View file

@ -8,5 +8,6 @@ void main() {
expect(VideoMetadataFormatter.parseVideoDate('2011-05-08T03:46+09:00'), DateTime(2011, 5, 7, 18, 46).add(localOffset).millisecondsSinceEpoch);
expect(VideoMetadataFormatter.parseVideoDate('UTC 2021-05-30 19:14:21'), DateTime(2021, 5, 30, 19, 14, 21).millisecondsSinceEpoch);
expect(VideoMetadataFormatter.parseVideoDate('2021/10/31 21:23:17'), DateTime(2021, 10, 31, 21, 23, 17).millisecondsSinceEpoch);
expect(VideoMetadataFormatter.parseVideoDate('2021-09-10T7:14:49 pmZ'), DateTime(2021, 9, 10, 19, 14, 49).millisecondsSinceEpoch);
});
}