fc_native_video_thumbnail 2.0.0
fc_native_video_thumbnail: ^2.0.0 copied to clipboard
A Flutter plugin to create video thumbnails via native APIs.
fc_native_video_thumbnail #
A Flutter plugin to create video thumbnails via native APIs.
| iOS | Android | macOS | Windows | |
|---|---|---|---|---|
| Source (Path) | ✅ | ✅ | ✅ | ✅ |
| Source (Uri) | ✅ | ✅ | ✅ | - |
| At (Second) | ✅ | - | ✅ | - |
Usage #
There are 2 APIs:
saveThumbnailToFilesaves the thumbnail to a file path.- Returns true if thumbnail was successfully created. Or false if thumbnail is not available.
- Throws if error happens during thumbnail generation.
saveThumbnailToBytesreturns the thumbnail as a byte array.- Returns the thumbnail as bytes if successfully created. Or null if thumbnail is not available.
- Throws if error happens during thumbnail generation.
Example:
final plugin = FcNativeVideoThumbnail();
try {
/// Extracts a thumbnail from [srcFile] with the given options and saves it to [destFile].
///
/// [srcFile] source video path or Uri (See [srcFileUri]).
/// [srcFileUri] If true, [srcFile] is a Uri (Android/iOS/macOS only).
/// [destFile] thumbnail save path.
/// [width] / [height] max dimensions of the thumbnail image.
/// Windows doesn't support non-square thumbnail images, only [width] is used in Windows, resulting in a [width]x[width] max thumbnail.
/// [format] only "jpeg" is supported. Defaults to "jpeg".
/// [quality] a fallback value for the quality of the thumbnail image (0-100). May be ignored by the platform.
/// [at] the time position of the thumbnail in seconds.
/// Defaults to 1 on iOS/macOS.
/// Ignored on Windows/Android.
final generated = await plugin.saveThumbnailToFile(
srcFile: srcFile,
destFile: destFile,
width: 300,
height: 300,
format: 'jpeg',
quality: 90,
at: 1);
// `saveThumbnailToBytes` has the same options as `saveThumbnailToFile` except `destFile`.
final thumbnailBytes = await plugin.saveThumbnailToBytes(
srcFile: srcFile,
width: 300,
height: 300,
format: 'jpeg',
quality: 90);
} catch (err) {
// Handle platform errors.
}