implement get chapters api in media information

pull/181/head
suman maharjan 4 years ago
parent 39911c0e79
commit 6c21daea36
  1. 36
      flutter/flutter/lib/chapter.dart
  2. 26
      flutter/flutter/lib/media_information.dart

@ -0,0 +1,36 @@
/*
* Copyright (c) 2019-2021 Taner Sener
*
* This file is part of FFmpegKit.
*
* FFmpegKit is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FFmpegKit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/
class Tags {
String title;
Tags(this.title);
}
class Chapter {
int id;
String timeBase;
int start;
int end;
String startTime;
String endTime;
Tags? tags;
Chapter(this.id, this.timeBase, this.start, this.end, this.startTime,
this.endTime, this.tags);
}

@ -17,6 +17,7 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
import 'chapter.dart';
import 'stream_information.dart'; import 'stream_information.dart';
/// Media information class. /// Media information class.
@ -87,6 +88,31 @@ class MediaInformation {
return list; return list;
} }
/// Returns all chapters
List<Chapter>? getChapters() {
final List<Chapter> list = List<Chapter>.empty(growable: true);
List<Chapter> chapters = List.empty(growable: true);
if (_allProperties!["chapters"] != null) {
chapters = <Chapter>[];
_allProperties!['chapters'].forEach((Map<String, 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'];
Tags? tags = null;
if (chapter['tags'] != null) {
tags = Tags(chapter['tags']['title'] ?? "");
}
chapters.add(
new Chapter(id, timeBase, start, end, startTime, endTime, tags));
});
}
list.addAll(chapters);
return list;
}
/// Returns all media properties. /// Returns all media properties.
Map<dynamic, dynamic>? getMediaProperties() => Map<dynamic, dynamic>? getMediaProperties() =>
this._allProperties?[keyMediaProperties]; this._allProperties?[keyMediaProperties];

Loading…
Cancel
Save