diff --git a/flutter/flutter/lib/chapter.dart b/flutter/flutter/lib/chapter.dart
index 2dc47c3..cbf7bfc 100644
--- a/flutter/flutter/lib/chapter.dart
+++ b/flutter/flutter/lib/chapter.dart
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 Taner Sener
+ * Copyright (c) 2021 Taner Sener
*
* This file is part of FFmpegKit.
*
@@ -17,21 +17,51 @@
* along with FFmpegKit. If not, see .
*/
+/// Chapter class.
class Chapter {
- int id;
- String timeBase;
- int start;
- int end;
- String startTime;
- String endTime;
- Tags tags;
+ static const keyId = "id";
+ static const keyTimeBase = "time_base";
+ static const keyStart = "start";
+ static const keyStartTime = "start_time";
+ static const keyEnd = "end";
+ static const keyEndTime = "end_time";
+ static const keyTags = "tags";
- Chapter(this.id, this.timeBase, this.start, this.end, this.startTime,
- this.endTime, this.tags);
-}
-
-class Tags {
- String title;
-
- Tags(this.title);
+ Map? _allProperties;
+
+ /// Creates a new [Chapter] instance
+ Chapter(this._allProperties);
+
+ /// Returns id.
+ int? getId() => this.getNumberProperty(Chapter.keyId)?.toInt();
+
+ /// Returns time base.
+ String? getTimeBase() => this.getStringProperty(Chapter.keyTimeBase);
+
+ /// Returns start.
+ int? getStart() => this.getNumberProperty(Chapter.keyStart)?.toInt();
+
+ /// Returns start time.
+ String? getStartTime() => this.getStringProperty(Chapter.keyStartTime);
+
+ /// Returns end.
+ int? getEnd() => this.getNumberProperty(Chapter.keyEnd)?.toInt();
+
+ /// Returns end time.
+ String? getEndTime() => this.getStringProperty(Chapter.keyEndTime);
+
+ /// Returns all tags.
+ Map? getTags() => this.getProperties(Chapter.keyTags);
+
+ /// Returns the chapter property associated with the key.
+ String? getStringProperty(String key) => this._allProperties?[key];
+
+ /// Returns the chapter property associated with the key.
+ num? getNumberProperty(String key) => this._allProperties?[key];
+
+ /// Returns the chapter properties associated with the key.
+ dynamic getProperties(String key) => this._allProperties?[key];
+
+ /// Returns all properties found.
+ Map? getAllProperties() => this._allProperties;
}
diff --git a/flutter/flutter/lib/ffprobe_kit.dart b/flutter/flutter/lib/ffprobe_kit.dart
index 87e2aff..47d7e2b 100644
--- a/flutter/flutter/lib/ffprobe_kit.dart
+++ b/flutter/flutter/lib/ffprobe_kit.dart
@@ -76,6 +76,7 @@ class FFprobeKit {
"json",
"-show_format",
"-show_streams",
+ "-show_chapters",
"-i",
path
];
diff --git a/flutter/flutter/lib/media_information.dart b/flutter/flutter/lib/media_information.dart
index cc30e2a..83560f1 100644
--- a/flutter/flutter/lib/media_information.dart
+++ b/flutter/flutter/lib/media_information.dart
@@ -88,25 +88,17 @@ class MediaInformation {
return list;
}
- /// Returns all chapters
+ /// Returns all chapters found as a list.
List getChapters() {
final List list = List.empty(growable: true);
- List chapters = List.empty(growable: true);
- if (_allProperties?["chapters"] != null) {
- chapters = [];
- _allProperties!['chapters'].forEach((dynamic chapter) {
- final int id = chapter['id'];
- final String timeBase = chapter['time_base'];
- final int start = chapter['start'];
- final int end = chapter['end'];
- final String startTime = chapter['start_time'];
- final String endTime = chapter['end_time'];
- final Tags tags = Tags(chapter['tags']['title'] ?? "");
- chapters.add(
- new Chapter(id, timeBase, start, end, startTime, endTime, tags));
- });
- }
- list.addAll(chapters);
+
+ dynamic createChapter(Map chapterProperties) =>
+ list.add(new Chapter(chapterProperties));
+
+ this._allProperties?["chapters"]?.forEach((Object? chapter) {
+ createChapter(chapter as Map);
+ });
+
return list;
}
diff --git a/flutter/flutter/lib/stream_information.dart b/flutter/flutter/lib/stream_information.dart
index 3785a17..eb546b6 100644
--- a/flutter/flutter/lib/stream_information.dart
+++ b/flutter/flutter/lib/stream_information.dart
@@ -119,6 +119,6 @@ class StreamInformation {
/// Returns the stream properties associated with the key.
dynamic getProperties(String key) => this._allProperties?[key];
- /// Returns all properties found.d
+ /// Returns all properties found.
Map? getAllProperties() => this._allProperties;
}