lint
This commit is contained in:
@@ -5,12 +5,14 @@ import 'package:synchronized/synchronized.dart';
|
||||
import 'package:video_compress/video_compress.dart';
|
||||
import 'package:video_thumbnail/video_thumbnail.dart';
|
||||
|
||||
///
|
||||
class IVideoService {
|
||||
IVideoService._();
|
||||
|
||||
/// Singleton instance of [IVideoService]
|
||||
static final IVideoService instance = IVideoService._();
|
||||
final _lock = Lock();
|
||||
|
||||
IVideoService._();
|
||||
|
||||
/// compress video from [path]
|
||||
/// compress video from [path] return [Future<MediaInfo>]
|
||||
///
|
||||
@@ -26,18 +28,20 @@ class IVideoService {
|
||||
/// );
|
||||
/// debugPrint(info.toJson());
|
||||
/// ```
|
||||
Future<MediaInfo?> compressVideo(String? path) async {
|
||||
return _lock.synchronized(() {
|
||||
return VideoCompress.compressVideo(
|
||||
path!,
|
||||
Future<MediaInfo?> compressVideo(String? path) async => _lock.synchronized(
|
||||
() => VideoCompress.compressVideo(
|
||||
path!,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/// Generates a thumbnail image data in memory as UInt8List, it can be easily used by Image.memory(...).
|
||||
/// The video can be a local video file, or an URL repreents iOS or Android native supported video format.
|
||||
/// Speicify the maximum height or width for the thumbnail or 0 for same resolution as the original video.
|
||||
/// The lower quality value creates lower quality of the thumbnail image, but it gets ignored for PNG format.
|
||||
/// Generates a thumbnail image data in memory as UInt8List,
|
||||
/// it can be easily used by Image.memory(...).
|
||||
/// The video can be a local video file, or an URL repreents iOS or
|
||||
/// Android native supported video format.
|
||||
/// Speicify the maximum height or width for the thumbnail or 0 for
|
||||
/// same resolution as the original video.
|
||||
/// The lower quality value creates lower quality of the thumbnail image,
|
||||
/// but it gets ignored for PNG format.
|
||||
Future<Uint8List?> generateVideoThumbnail({
|
||||
required String video,
|
||||
ImageFormat imageFormat = ImageFormat.PNG,
|
||||
@@ -45,17 +49,17 @@ class IVideoService {
|
||||
int maxWidth = 0,
|
||||
int timeMs = 0,
|
||||
int quality = 10,
|
||||
}) {
|
||||
return VideoThumbnail.thumbnailData(
|
||||
video: video,
|
||||
imageFormat: imageFormat,
|
||||
maxHeight: maxHeight,
|
||||
maxWidth: maxWidth,
|
||||
timeMs: timeMs,
|
||||
quality: quality,
|
||||
);
|
||||
}
|
||||
}) =>
|
||||
VideoThumbnail.thumbnailData(
|
||||
video: video,
|
||||
imageFormat: imageFormat,
|
||||
maxHeight: maxHeight,
|
||||
maxWidth: maxWidth,
|
||||
timeMs: timeMs,
|
||||
quality: quality,
|
||||
);
|
||||
}
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
/// Get instance of [IVideoService]
|
||||
IVideoService get VideoService => IVideoService.instance;
|
||||
|
||||
Reference in New Issue
Block a user