generateCoverThumbnails function
Stream<List<CoverData> >
generateCoverThumbnails(
- VideoEditorController controller, {
- required int quantity,
- int quality = 10,
Implementation
Stream<List<CoverData>> generateCoverThumbnails(
VideoEditorController controller, {
required int quantity,
int quality = 10,
}) async* {
final int duration = controller.isTrimmed
? controller.trimmedDuration.inMilliseconds
: controller.videoDuration.inMilliseconds;
final double eachPart = duration / quantity;
List<CoverData> byteList = [];
for (int i = 0; i < quantity; i++) {
try {
final CoverData bytes = await generateSingleCoverThumbnail(
controller.file.path,
timeMs: (controller.isTrimmed
? (eachPart * i) + controller.startTrim.inMilliseconds
: (eachPart * i))
.toInt(),
quality: quality,
);
if (bytes.thumbData != null) {
byteList.add(bytes);
}
} catch (e) {
debugPrint(e.toString());
}
yield byteList;
}
}