|
@@ -42,21 +42,8 @@ public class RNThumbnailModule extends ReactContextBaseJavaModule {
|
42
|
42
|
filePath = filePath.replace("file://","");
|
43
|
43
|
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
44
|
44
|
retriever.setDataSource(filePath);
|
45
|
|
- int videoWidth = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
|
46
|
|
- int videoHeight = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
|
47
|
|
-
|
48
|
45
|
Bitmap image = retriever.getFrameAtTime(1000000, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
|
49
|
46
|
|
50
|
|
- int bitmapWidth = image.getWidth();
|
51
|
|
- int bitmapHeight = image.getHeight();
|
52
|
|
-
|
53
|
|
- if ((bitmapWidth > bitmapHeight) != (videoWidth > videoHeight)) {
|
54
|
|
- // we need to rotate image
|
55
|
|
- Matrix matrix = new Matrix();
|
56
|
|
- matrix.postRotate(-90);
|
57
|
|
- image = Bitmap.createBitmap(image, 0, 0, bitmapWidth, bitmapHeight, matrix, true);
|
58
|
|
- }
|
59
|
|
-
|
60
|
47
|
String fullPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/thumb";
|
61
|
48
|
|
62
|
49
|
try {
|