This repository was archived by the owner on Oct 10, 2024. It is now read-only.
This repository was archived by the owner on Oct 10, 2024. It is now read-only.
Compress Video with Worker Manager #60
Open
Description
I need to compress video before uploading on server. I had implement video compress code with Worker Manager with await. But it terminate at video compress line.
Please suggest that how to implement with with Worker Manager.
Worker Manager
https://pub.dev/packages/workmanager
With Worker Manager
String? compressFilePath =
await compressVideo(attachment.localfilePath?.path ?? "");
Video Compress Code
Future<String?> compressVideo(String filePath) async {
try {
LightCompressor lightCompressor = LightCompressor();
final String videoName =
'PINEWS_${DateTime.now().millisecondsSinceEpoch}.mp4';
final Result response = await lightCompressor.compressVideo(
path: filePath,
videoQuality: VideoQuality.medium,
isMinBitrateCheckEnabled: false,
video: Video(videoName: videoName),
android: AndroidConfig(isSharedStorage: true, saveAt: SaveAt.Movies),
ios: IOSConfig(saveInGallery: false),
);
if (response is OnSuccess) {
return response.destinationPath;
} else if (response is OnFailure) {
} else if (response is OnCancelled) {
}
return null;
} catch (error) {
return null;
}
}
Metadata
Metadata
Assignees
Labels
No labels