feat(android,interface): Implement video thumbnail generation
This commit is contained in:
@@ -756,6 +756,36 @@ class MoxplatformApi {
|
||||
}
|
||||
}
|
||||
|
||||
/// Media APIs
|
||||
Future<bool> generateVideoThumbnail(
|
||||
String arg_src, String arg_dest, int arg_maxWidth) async {
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.generateVideoThumbnail',
|
||||
codec,
|
||||
binaryMessenger: _binaryMessenger);
|
||||
final List<Object?>? replyList = await channel
|
||||
.send(<Object?>[arg_src, arg_dest, arg_maxWidth]) as List<Object?>?;
|
||||
if (replyList == null) {
|
||||
throw PlatformException(
|
||||
code: 'channel-error',
|
||||
message: 'Unable to establish connection on channel.',
|
||||
);
|
||||
} else if (replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: replyList[0]! as String,
|
||||
message: replyList[1] as String?,
|
||||
details: replyList[2],
|
||||
);
|
||||
} else if (replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (replyList[0] as bool?)!;
|
||||
}
|
||||
}
|
||||
|
||||
/// Stubs
|
||||
Future<void> eventStub(NotificationEvent arg_event) async {
|
||||
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
|
||||
|
||||
@@ -12,4 +12,9 @@ abstract class PlatformImplementation {
|
||||
/// Opens the page for battery optimisations. If not supported on the
|
||||
/// platform, does nothing.
|
||||
Future<void> openBatteryOptimisationSettings();
|
||||
|
||||
/// Attempt to generate a thumbnail for the video file at [src], scale it, while keeping the
|
||||
/// aspect ratio in tact to [width], and write it to [dest]. If we were successful, returns true.
|
||||
/// If no thumbnail was generated, returns false.
|
||||
Future<bool> generateVideoThumbnail(String src, String dest, int width);
|
||||
}
|
||||
|
||||
@@ -14,4 +14,9 @@ class StubPlatformImplementation extends PlatformImplementation {
|
||||
|
||||
@override
|
||||
Future<void> openBatteryOptimisationSettings() async {}
|
||||
|
||||
@override
|
||||
Future<bool> generateVideoThumbnail(
|
||||
String src, String dest, int width) async =>
|
||||
false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user