justsoft / video_thumbnail

This plugin generates thumbnail from video file or URL. It returns image in memory or writes into a file. It offers rich options to control the image format, resolution and quality. Supports iOS and Android.
MIT License
183 stars 238 forks source link

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long #66

Closed vipinnegi90 closed 3 years ago

vipinnegi90 commented 3 years ago

I've been trying to figure out this problem for a while, But no luck :(. I used ImagePicker to pick a video.

final _picker = ImagePicker();
PickedFile pickedVideo = await _picker.getVideo(source: ImageSource.gallery);
File videoFile = File(pickedVideo.path);
final thumbnailPath = await VideoThumbnail.thumbnailFile(
  video: videoFile.path,
  imageFormat: ImageFormat.JPEG,
  maxWidth: 500,
  quality: 25,
);
File videoThumbnail = File(thumbnailPath);

Read and Write permissions are added in Manifest. Yes videos are playable Using : video_thumbnail: ^0.3.2 I've video_player: 2.0.2 too in my pubspec.yaml (does it cause any conflict?)

Error:

E/MethodChannel#video_thumbnail(29342): Failed to handle method call
E/MethodChannel#video_thumbnail(29342): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
E/MethodChannel#video_thumbnail(29342):     at xyz.justsoft.video_thumbnail.VideoThumbnailPlugin.onMethodCall(VideoThumbnailPlugin.java:59)
E/MethodChannel#video_thumbnail(29342):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#video_thumbnail(29342):     at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#video_thumbnail(29342):     at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#video_thumbnail(29342):     at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#video_thumbnail(29342):     at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#video_thumbnail(29342):     at android.os.Looper.loop(Looper.java:160)
E/MethodChannel#video_thumbnail(29342):     at android.app.ActivityThread.main(ActivityThread.java:6718)
E/MethodChannel#video_thumbnail(29342):     at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#video_thumbnail(29342):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#video_thumbnail(29342):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter (29342): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(error, java.lang.Integer cannot be cast to java.lang.Long, null, java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
E/flutter (29342):  at xyz.justsoft.video_thumbnail.VideoThumbnailPlugin.onMethodCall(VideoThumbnailPlugin.java:59)
E/flutter (29342):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (29342):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (29342):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/flutter (29342):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (29342):  at android.os.MessageQueue.next(MessageQueue.java:326)
E/flutter (29342):  at android.os.Looper.loop(Looper.java:160)
E/flutter (29342):  at android.app.ActivityThread.main(ActivityThread.java:6718)
E/flutter (29342):  at java.lang.reflect.Method.invoke(Native Method)
E/flutter (29342):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/flutter (29342):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
E/flutter (29342): )
E/flutter (29342): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581:7)
E/flutter (29342): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18)
E/flutter (29342): <asynchronous suspension>
E/flutter (29342): #2      VideoThumbnail.thumbnailFile (package:video_thumbnail/video_thumbnail.dart:44:12)
E/flutter (29342): <asynchronous suspension>
E/flutter (29342): #3      Utils.addGalleryVideo (package:starringyou/utils.dart:187:27)
E/flutter (29342): <asynchronous suspension>
E/flutter (29342): #4      BottomSheetUploadVideo.build.<anonymous closure>.<anonymous closure> (package:starringyou/components/bottom-sheet-upload-video.dart:64:35)
E/flutter (29342): <asynchronous suspension>
justsoft commented 3 years ago

Sorry, that is my fault, please specify the version 0.3.1 to see the problem goes away.

justsoft commented 3 years ago

Or please try 0.3.3