diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-17 15:31:16 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-17 15:31:16 +0300 |
| commit | c11b7c145fc1b2db6c1ed29a7abd739d0f6cbf3b (patch) | |
| tree | 4db8478fded8f3e1ad832b2788f6f82888a8f3ad /player-android/lib/models/media.dart | |
| parent | 914bd7cd6aa14e839332a98d91c30b19865b0cf2 (diff) | |
Add player-android/ Flutter skeleton
Diffstat (limited to 'player-android/lib/models/media.dart')
| -rw-r--r-- | player-android/lib/models/media.dart | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/player-android/lib/models/media.dart b/player-android/lib/models/media.dart new file mode 100644 index 0000000..7330bca --- /dev/null +++ b/player-android/lib/models/media.dart @@ -0,0 +1,16 @@ +import 'json_helpers.dart'; + +class Media { + final int id, setId, bitrate, fileSizeBytes, width, height, playCount; + final String relPath, fileName, absPath, type, codec, resolution, thumbnailPath; + final double duration; + final bool favorite; + final List<String> tags; + final DateTime? deletedAt, createdAt; + + const Media({required this.id, required this.setId, required this.relPath, required this.fileName, required this.absPath, required this.type, required this.duration, required this.codec, required this.resolution, required this.bitrate, required this.fileSizeBytes, required this.width, required this.height, required this.thumbnailPath, required this.playCount, this.favorite = false, this.tags = const [], this.deletedAt, this.createdAt}); + + factory Media.fromJson(Map<String, dynamic> json) => Media(id: json['id'] as int? ?? 0, setId: json['set_id'] as int? ?? 0, relPath: json['rel_path'] as String? ?? '', fileName: json['file_name'] as String? ?? '', absPath: json['abs_path'] as String? ?? '', type: json['type'] as String? ?? '', duration: (json['duration'] as num?)?.toDouble() ?? 0, codec: json['codec'] as String? ?? '', resolution: json['resolution'] as String? ?? '', bitrate: json['bitrate'] as int? ?? 0, fileSizeBytes: json['file_size_bytes'] as int? ?? 0, width: json['width'] as int? ?? 0, height: json['height'] as int? ?? 0, thumbnailPath: json['thumbnail_path'] as String? ?? '', playCount: json['play_count'] as int? ?? 0, favorite: json['favorite'] as bool? ?? false, tags: (json['tags'] as List<dynamic>? ?? const []).cast<String>(), deletedAt: dateTimeFromJson(json['deleted_at']), createdAt: dateTimeFromJson(json['created_at'])); + + Map<String, dynamic> toJson() => {'id': id, 'set_id': setId, 'rel_path': relPath, 'file_name': fileName, 'abs_path': absPath, 'type': type, 'duration': duration, 'codec': codec, 'resolution': resolution, 'bitrate': bitrate, 'file_size_bytes': fileSizeBytes, 'width': width, 'height': height, 'thumbnail_path': thumbnailPath, 'play_count': playCount, 'favorite': favorite, 'tags': tags, 'deleted_at': dateTimeToJson(deletedAt), 'created_at': dateTimeToJson(createdAt)}; +} |
