initialize method
Attempts to open the given video File and load metadata about the video.
Update the trim position depending on the maxDuration param
Generate the default cover _selectedCover
Initialize minCrop & maxCrop values based on aspectRatio
Implementation
Future<void> initialize({double? aspectRatio}) async {
await _video.initialize().then((_) {
_videoWidth = _video.value.size.width;
_videoHeight = _video.value.size.height;
});
_video.addListener(_videoListener);
_video.setLooping(true);
// if no [maxDuration] param given, maxDuration is the videoDuration
_maxDuration = _maxDuration == Duration.zero ? videoDuration : _maxDuration;
// Trim straight away when maxDuration is lower than video duration
if (_maxDuration < videoDuration) {
updateTrim(
0.0, _maxDuration.inMilliseconds / videoDuration.inMilliseconds);
} else {
_updateTrimRange();
}
cropAspectRatio(aspectRatio);
generateDefaultCoverThumbnail();
notifyListeners();
}