Skip to content

Commit 6f6864c

Browse files
committed
[Android, LogLevel] Support for control over log level printings in Android platform
1 parent 6f6bfbd commit 6f6864c

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

android/src/main/kotlin/com/example/video_compress/VideoCompressPlugin.kt

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.otaliastudios.transcoder.strategy.DefaultVideoStrategies
1010
import com.otaliastudios.transcoder.strategy.DefaultVideoStrategy
1111
import com.otaliastudios.transcoder.strategy.TrackStrategy
1212
import com.otaliastudios.transcoder.strategy.size.*
13+
import com.otaliastudios.transcoder.internal.Logger
1314
import io.flutter.plugin.common.MethodCall
1415
import io.flutter.plugin.common.MethodChannel
1516
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
@@ -24,6 +25,8 @@ import java.util.*
2425
*/
2526
class VideoCompressPlugin private constructor(private val activity: Activity, private val context: Context, private val channel: MethodChannel) : MethodCallHandler {
2627

28+
private val TAG = "VideoCompressPlugin"
29+
private val LOG = Logger(TAG)
2730
var channelName = "video_compress"
2831
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
2932

@@ -48,6 +51,11 @@ class VideoCompressPlugin private constructor(private val activity: Activity, pr
4851
"deleteAllCache" -> {
4952
result.success(Utility(channelName).deleteAllCache(context, result));
5053
}
54+
"setLogLevel" -> {
55+
val logLevel = call.argument<Int>("logLevel")!!
56+
Logger.setLogLevel(logLevel)
57+
result.success(true);
58+
}
5159
"cancelCompression" -> {
5260
result.success(false);
5361
//TODO: Made Transcoder.into Global to call Transcoder.cancel(true); here

example/lib/main.dart

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class _MyHomePageState extends State<MyHomePage> {
9898
floatingActionButton: FloatingActionButton(
9999
onPressed: () async {
100100
File file = await ImagePicker.pickVideo(source: ImageSource.gallery);
101+
await VideoCompress.setLogLevel(3);
101102
final info = await VideoCompress.compressVideo(
102103
file.path,
103104
quality: VideoQuality.MediumQuality,

ios/Classes/SwiftVideoCompressPlugin.swift

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public class SwiftVideoCompressPlugin: NSObject, FlutterPlugin {
4949
case "deleteAllCache":
5050
Utility.deleteFile(Utility.basePath(), clear: true)
5151
result(true)
52+
case "setLogLevel":
53+
result(true)
5254
default:
5355
result(FlutterMethodNotImplemented)
5456
}

lib/src/video_compressor.dart

+6
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ class VideoCompress {
167167
static Future<bool> deleteAllCache() async {
168168
return await _invoke<bool>('deleteAllCache');
169169
}
170+
171+
static Future<void> setLogLevel(int logLevel) async {
172+
return await _invoke<void>('setLogLevel', {
173+
'logLevel': logLevel,
174+
});
175+
}
170176
}
171177

172178
class ObservableBuilder<T> {

0 commit comments

Comments
 (0)