Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thumbnail position fixes #289

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.1.5
- Fix getThumbnail position being supplied in milliseconds, but used as microseconds in Android and seconds in iOS

## 3.1.4

- Removes references to v1 Flutter Android embedding classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ class VideoCompressPlugin : MethodCallHandler, FlutterPlugin {
val path = call.argument<String>("path")
val quality = call.argument<Int>("quality")!!
val position = call.argument<Int>("position")!! // to long
ThumbnailUtility(channelName).getByteThumbnail(path!!, quality, position.toLong(), result)
ThumbnailUtility(channelName).getByteThumbnail(path!!, quality, position.toLong() * 1000, result)
}
"getFileThumbnail" -> {
val path = call.argument<String>("path")
val quality = call.argument<Int>("quality")!!
val position = call.argument<Int>("position")!! // to long
ThumbnailUtility("video_compress").getFileThumbnail(context, path!!, quality,
position.toLong(), result)
position.toLong() * 1000, result)
}
"getMediaInfo" -> {
val path = call.argument<String>("path")
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/SwiftVideoCompressPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class SwiftVideoCompressPlugin: NSObject, FlutterPlugin {
assetImgGenerate.appliesPreferredTrackTransform = true

let timeScale = CMTimeScale(track.nominalFrameRate)
let time = CMTimeMakeWithSeconds(Float64(truncating: position),preferredTimescale: timeScale)
let time = CMTime(seconds: Double(position) / 1000.0, preferredTimescale: timeScale)
guard let img = try? assetImgGenerate.copyCGImage(at:time, actualTime: nil) else {
return nil
}
Expand Down
4 changes: 3 additions & 1 deletion lib/src/media/media_data.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: constant_identifier_names

abstract class Enum<T> {
final T _value;

Expand Down Expand Up @@ -106,5 +108,5 @@ class MediaMetadataRetriever<int> extends Enum<int> {
/// [Android] API level 10
static const METADATA_KEY_YEAR = MediaMetadataRetriever(8);

const MediaMetadataRetriever(int value) : super(value);
const MediaMetadataRetriever(super.value);
}
1 change: 0 additions & 1 deletion lib/src/video_compress/video_compressor.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/video_compress.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
library video_compress;

export 'src/video_compress/video_compressor.dart';
export 'src/video_compress/video_quality.dart';
export 'src/media/media_info.dart';
Expand Down
2 changes: 1 addition & 1 deletion macos/Classes/VideoCompressPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class VideoCompressPlugin: NSObject, FlutterPlugin {
assetImgGenerate.appliesPreferredTrackTransform = true

let timeScale = CMTimeScale(track.nominalFrameRate)
let time = CMTimeMakeWithSeconds(Float64(truncating: position),preferredTimescale: timeScale)
let time = CMTime(seconds: Double(position) / 1000.0, preferredTimescale: timeScale)
guard let img = try? assetImgGenerate.copyCGImage(at:time, actualTime: nil) else {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: video_compress
description: Light library of video manipulation of Flutter. Compress video, remove audio, get video thumbnail from dart code.
version: 3.1.4
version: 3.1.5
homepage: https://github.com/jonataslaw/VideoCompress

environment:
Expand Down