From 8f3e394df363bbb4d7f1b3f9eb153a0f54ba2bcc Mon Sep 17 00:00:00 2001 From: Bidhan Rai Date: Thu, 23 Jun 2022 14:04:59 +0545 Subject: [PATCH 1/4] updated some deprecated code in example and removed unused imports from deepar_controller --- .../android/app/src/main/AndroidManifest.xml | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 14 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/ios/Runner/Info.plist | 17 +- example/lib/config.dart | 4 +- example/lib/main.dart | 160 +++++++++--------- ios/Classes/SwiftCameraDeepArPlugin.swift | 2 +- lib/src/deepar_controller.dart | 2 - 8 files changed, 105 insertions(+), 98 deletions(-) diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 98065d5..e0630d5 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -30,7 +30,7 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 9a571e4..574a710 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -155,7 +155,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1250; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -356,7 +356,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = BCK4EQC3CG; + DEVELOPMENT_TEAM = WJUL2YM2QG; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -371,7 +371,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.cameraDeepArExample; + PRODUCT_BUNDLE_IDENTIFIER = com.cameraDeepAR; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -495,7 +495,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = BCK4EQC3CG; + DEVELOPMENT_TEAM = WJUL2YM2QG; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -510,7 +510,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.cameraDeepArExample; + PRODUCT_BUNDLE_IDENTIFIER = com.cameraDeepAR; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -526,7 +526,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = BCK4EQC3CG; + DEVELOPMENT_TEAM = WJUL2YM2QG; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -541,7 +541,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.cameraDeepArExample; + PRODUCT_BUNDLE_IDENTIFIER = com.cameraDeepAR; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 7785fe3..c87d15a 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -22,6 +24,14 @@ $(FLUTTER_BUILD_NUMBER) LSRequiresIPhoneOS + NSCameraUsageDescription + Allows you to capture your best moment + NSMicrophoneUsageDescription + Spark buz needs access to your mic to help your record voice notes on chat/message conversations + NSPhotoLibraryAddUsageDescription + Allows you to capture your best moment + NSPhotoLibraryUsageDescription + Apps wants to select a photo UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -41,14 +51,7 @@ UIViewControllerBasedStatusBarAppearance - NSCameraUsageDescription - Allows you to capture your best moment io.flutter.embedded_views_preview - NSPhotoLibraryAddUsageDescription - Allows you to capture your best moment - NSMicrophoneUsageDescription - Spark buz needs access to your mic to help your record voice notes on chat/message conversations - diff --git a/example/lib/config.dart b/example/lib/config.dart index 66c5ac5..840ac93 100644 --- a/example/lib/config.dart +++ b/example/lib/config.dart @@ -10,9 +10,9 @@ import 'package:camera_deep_ar/camera_deep_ar.dart'; DeepArConfig config = DeepArConfig( androidKey: - "3b58c448bd650192e7c53d965cfe5dc1c341d2568b663a3962b7517c4ac6eeed0ba1fb2afe491a4b", + "ca5d08279fb7a9a522891438f99fa688b41053df7a63f6564065f94b8f8ac743aec0006389189bc2", ioskey: - "53618212114fc16bbd7499c0c04c2ca11a4eed188dc20ed62a7f7eec02b41cb34d638e72945a6bf6", + "3cf1556ee87a073df61f9763a1307edd7aafe6f7e84d8fbcfdef1be98b1280133d5eb986834e6882", displayMode: DisplayMode.camera, // displayMode: DisplayMode.camera, ); diff --git a/example/lib/main.dart b/example/lib/main.dart index 92941e9..ce9de63 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -38,14 +38,10 @@ class _MyAppState extends State { switch (cameraMode) { case CameraMode.mask: return masks; - break; case CameraMode.effect: return effects; - break; - case CameraMode.filter: return filters; - break; default: return masks; } @@ -57,8 +53,8 @@ class _MyAppState extends State { "assets/bigmouth", "assets/lion", "assets/dalmatian", - "assets/bcgseg", - "assets/look2", + // "assets/bcgseg", + // "assets/look2", "assets/fatify", "assets/flowers", "assets/grumpycat", @@ -110,7 +106,7 @@ class _MyAppState extends State { @override void dispose() { - deepArController?.dispose(); + deepArController.dispose(); super.dispose(); } @@ -139,78 +135,87 @@ class _MyAppState extends State { textAlign: TextAlign.center, style: TextStyle(fontSize: 14, color: Colors.white), ), - SizedBox( - height: 20, - ), - Container( - child: Row( - children: [ - Expanded( - child: FlatButton( - onPressed: () { - if (null == deepArController) return; - if (isRecording) return; - deepArController.snapPhoto(); - }, - child: Icon(Icons.camera_enhance_outlined), - color: Colors.white, - padding: EdgeInsets.all(15), + + SizedBox(height: 20), + + //take photo video widget + Row( + children: [ + Expanded( + child: TextButton( + onPressed: () { + if (isRecording) return; + deepArController.snapPhoto(); + }, + child: Icon(Icons.camera_enhance_outlined), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.white), + padding: MaterialStateProperty.all(EdgeInsets.all(15)), ), ), - if (displayMode == DisplayMode.image) - Expanded( - child: FlatButton( - onPressed: () async { - String path = "assets/testImage.png"; - final file = await deepArController - .createFileFromAsset(path, "test"); + ), + if (displayMode == DisplayMode.image) + Expanded( + child: TextButton( + onPressed: () async { + // String path = "assets/testImage.png"; + // final file = await deepArController + // .createFileFromAsset(path, "testImage"); + // await Future.delayed(Duration(seconds: 1)); - // final file = await ImagePicker() - // .pickImage(source: ImageSource.gallery); - await Future.delayed(Duration(seconds: 1)); + final file = await ImagePicker() + .pickImage(source: ImageSource.gallery); + if(file != null) { deepArController.changeImage(file.path); - print("DAMON - Calling Change Image Flutter"); - }, - child: Icon(Icons.image), - color: Colors.orange, - padding: EdgeInsets.all(15), + } + print("DAMON - Calling Change Image Flutter"); + }, + child: Icon(Icons.image), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.orange), + padding: MaterialStateProperty.all(EdgeInsets.all(15)), ), ), - if (isRecording) - Expanded( - child: FlatButton( - onPressed: () { - if (null == deepArController) return; - deepArController.stopVideoRecording(); - isRecording = false; - setState(() {}); - }, - child: Icon(Icons.videocam_off), - color: Colors.red, - padding: EdgeInsets.all(15), + ), + + if (isRecording) + Expanded( + child: TextButton( + onPressed: () async{ + isRecording = false; + setState(() {}); + await deepArController.stopVideoRecording(); + + }, + child: Icon(Icons.videocam_off), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.red), + padding: MaterialStateProperty.all(EdgeInsets.all(15)), ), - ) - else - Expanded( - child: FlatButton( - onPressed: () { - if (null == deepArController) return; - deepArController.startVideoRecording(); - isRecording = true; - setState(() {}); - }, - child: Icon(Icons.videocam), - color: Colors.green, - padding: EdgeInsets.all(15), + ), + ) + else + Expanded( + child: TextButton( + onPressed: () { + deepArController.startVideoRecording(); + isRecording = true; + setState(() {}); + }, + child: Icon(Icons.videocam), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.green), + padding: MaterialStateProperty.all(EdgeInsets.all(15)), ), ), - ], - ), - ), - SizedBox( - height: 10, + ), + ], ), + + SizedBox(height: 10), + + //change effects widget SingleChildScrollView( padding: EdgeInsets.all(15), scrollDirection: Axis.horizontal, @@ -252,9 +257,10 @@ class _MyAppState extends State { }), ), ), - SizedBox( - height: 5, - ), + + SizedBox(height: 5), + + //change camera mode widget (mask/effect/filter) Row( children: List.generate(CameraMode.values.length, (p) { CameraMode mode = CameraMode.values[p]; @@ -290,14 +296,14 @@ class _MyAppState extends State { ); }), ), - SizedBox( - height: 5, - ), + + SizedBox(height: 5), + + //change display mode widget (camera/image) Row( children: List.generate(DisplayMode.values.length, (p) { DisplayMode mode = DisplayMode.values[p]; bool active = displayMode == mode; - return Expanded( child: Container( height: 40, @@ -305,7 +311,7 @@ class _MyAppState extends State { child: TextButton( onPressed: () async { displayMode = mode; - await deepArController.setDisplayMode( + deepArController.setDisplayMode( mode: mode); setState(() {}); }, @@ -329,7 +335,7 @@ class _MyAppState extends State { ), ); }), - ) + ), ], ), ), diff --git a/ios/Classes/SwiftCameraDeepArPlugin.swift b/ios/Classes/SwiftCameraDeepArPlugin.swift index 4ab1450..f441f6a 100644 --- a/ios/Classes/SwiftCameraDeepArPlugin.swift +++ b/ios/Classes/SwiftCameraDeepArPlugin.swift @@ -348,7 +348,7 @@ public class DeepArCameraView : NSObject,FlutterPlatformView,DeepARDelegate, Flu argument["methodName"] = key argument["data"] = data eventSink(argument) - + // DispatchQueue.main.async { // NSLog("sendResponse /\(String(describing: key)) /\(String(describing: data))") // guard let eventSink = self.eventSink else { return } diff --git a/lib/src/deepar_controller.dart b/lib/src/deepar_controller.dart index feef709..5dac3d5 100644 --- a/lib/src/deepar_controller.dart +++ b/lib/src/deepar_controller.dart @@ -2,9 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'package:camera_deep_ar/camera_deep_ar.dart'; -import 'package:camera_deep_ar/src/events.dart'; import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; From d5492b21b664d8b4955706e57ce8f79e25dfe70c Mon Sep 17 00:00:00 2001 From: Bidhan Rai Date: Thu, 23 Jun 2022 14:29:14 +0545 Subject: [PATCH 2/4] go to video preview after recoring complete in example app --- example/lib/main.dart | 436 +++++++++++++------------- example/lib/video_preview_widget.dart | 57 ++++ example/pubspec.yaml | 1 + 3 files changed, 283 insertions(+), 211 deletions(-) create mode 100644 example/lib/video_preview_widget.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index ce9de63..b24b22e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,12 +1,8 @@ -import 'dart:io'; - import 'package:camera_deep_ar/camera_deep_ar.dart'; +import 'package:camera_deep_ar_example/video_preview_widget.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:image_picker/image_picker.dart'; -import 'package:path_provider/path_provider.dart'; - import 'config.dart'; //https://github.com/daptee/question-color-deepAr-modified.git @@ -22,6 +18,25 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: MyHomePage(), + ); + } + +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({Key? key}) : super(key: key); + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + // CameraDeepArControllerX cameraDeepArController; // Effects currentEffect = Effects.none; // Filters currentFilter = Filters.none; @@ -97,6 +112,7 @@ class _MyAppState extends State { setState(() {}); }, onVideoRecordingComplete: (v) { _platformVersion = "onVideoRecordingComplete $v"; + Navigator.push(context, MaterialPageRoute(builder: (context)=> VideoPreviewWidget(videoPath: v,))); setState(() {}); }, onSwitchEffect: (v) { _platformVersion = "onSwitchEffect $v"; @@ -112,245 +128,243 @@ class _MyAppState extends State { @override Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - backgroundColor: Colors.black, - appBar: AppBar( - title: const Text('DeepAR Camera Example'), - ), - body: Stack( - children: [ - DeepArPreview(deepArController), - Align( - alignment: Alignment.bottomCenter, - child: Container( - padding: EdgeInsets.all(20), - //height: 250, - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text( - 'Response >>> : $_platformVersion\n', - textAlign: TextAlign.center, - style: TextStyle(fontSize: 14, color: Colors.white), - ), + return Scaffold( + backgroundColor: Colors.black, + appBar: AppBar( + title: const Text('DeepAR Camera Example'), + ), + body: Stack( + children: [ + DeepArPreview(deepArController), + Align( + alignment: Alignment.bottomCenter, + child: Container( + padding: EdgeInsets.all(20), + //height: 250, + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text( + 'Response >>> : $_platformVersion\n', + textAlign: TextAlign.center, + style: TextStyle(fontSize: 14, color: Colors.white), + ), - SizedBox(height: 20), + SizedBox(height: 20), - //take photo video widget - Row( - children: [ + //take photo video widget + Row( + children: [ + Expanded( + child: TextButton( + onPressed: () { + if (isRecording) return; + deepArController.snapPhoto(); + }, + child: Icon(Icons.camera_enhance_outlined), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.white), + padding: MaterialStateProperty.all(EdgeInsets.all(15)), + ), + ), + ), + if (displayMode == DisplayMode.image) Expanded( child: TextButton( - onPressed: () { - if (isRecording) return; - deepArController.snapPhoto(); + onPressed: () async { + // String path = "assets/testImage.png"; + // final file = await deepArController + // .createFileFromAsset(path, "testImage"); + // await Future.delayed(Duration(seconds: 1)); + + final file = await ImagePicker() + .pickImage(source: ImageSource.gallery); + + if(file != null) { + deepArController.changeImage(file.path); + } + print("DAMON - Calling Change Image Flutter"); }, - child: Icon(Icons.camera_enhance_outlined), + child: Icon(Icons.image), style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Colors.white), + backgroundColor: MaterialStateProperty.all(Colors.orange), padding: MaterialStateProperty.all(EdgeInsets.all(15)), ), ), ), - if (displayMode == DisplayMode.image) - Expanded( - child: TextButton( - onPressed: () async { - // String path = "assets/testImage.png"; - // final file = await deepArController - // .createFileFromAsset(path, "testImage"); - // await Future.delayed(Duration(seconds: 1)); - - final file = await ImagePicker() - .pickImage(source: ImageSource.gallery); - if(file != null) { - deepArController.changeImage(file.path); - } - print("DAMON - Calling Change Image Flutter"); + if (isRecording) + Expanded( + child: TextButton( + onPressed: () async{ + isRecording = false; + setState(() {}); + await deepArController.stopVideoRecording(); }, - child: Icon(Icons.image), - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Colors.orange), - padding: MaterialStateProperty.all(EdgeInsets.all(15)), - ), + child: Icon(Icons.videocam_off), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.red), + padding: MaterialStateProperty.all(EdgeInsets.all(15)), + ), + ), + ) + else + Expanded( + child: TextButton( + onPressed: () { + deepArController.startVideoRecording(); + isRecording = true; + setState(() {}); + }, + child: Icon(Icons.videocam), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.green), + padding: MaterialStateProperty.all(EdgeInsets.all(15)), ), ), + ), + ], + ), - if (isRecording) - Expanded( - child: TextButton( - onPressed: () async{ - isRecording = false; - setState(() {}); - await deepArController.stopVideoRecording(); + SizedBox(height: 10), - }, - child: Icon(Icons.videocam_off), - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Colors.red), - padding: MaterialStateProperty.all(EdgeInsets.all(15)), - ), - ), - ) - else - Expanded( - child: TextButton( - onPressed: () { - deepArController.startVideoRecording(); - isRecording = true; - setState(() {}); - }, - child: Icon(Icons.videocam), - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Colors.green), - padding: MaterialStateProperty.all(EdgeInsets.all(15)), - ), + //change effects widget + SingleChildScrollView( + padding: EdgeInsets.all(15), + scrollDirection: Axis.horizontal, + child: Row( + children: List.generate(effectList.length, (p) { + bool active = currentEffect == p; + String imgPath = effectList[p]; + return GestureDetector( + onTap: () async { + if (!deepArController.value.isInitialized) return; + currentEffect = p; + deepArController.switchEffect( + cameraMode, imgPath); + setState(() {}); + }, + child: Container( + margin: EdgeInsets.all(6), + width: active ? 70 : 55, + height: active ? 70 : 55, + alignment: Alignment.center, + child: Text( + "$p", + textAlign: TextAlign.center, + style: TextStyle( + fontWeight: active ? FontWeight.bold : null, + fontSize: active ? 16 : 14, + color: + active ? Colors.white : Colors.black), ), + decoration: BoxDecoration( + color: active ? Colors.orange : Colors.white, + border: Border.all( + color: + active ? Colors.orange : Colors.white, + width: active ? 2 : 0), + shape: BoxShape.circle), ), - ], + ); + }), ), + ), + + SizedBox(height: 5), - SizedBox(height: 10), + //change camera mode widget (mask/effect/filter) + Row( + children: List.generate(CameraMode.values.length, (p) { + CameraMode mode = CameraMode.values[p]; + bool active = cameraMode == mode; - //change effects widget - SingleChildScrollView( - padding: EdgeInsets.all(15), - scrollDirection: Axis.horizontal, - child: Row( - children: List.generate(effectList.length, (p) { - bool active = currentEffect == p; - String imgPath = effectList[p]; - return GestureDetector( - onTap: () async { - if (!deepArController.value.isInitialized) return; - currentEffect = p; - deepArController.switchEffect( - cameraMode, imgPath); + return Expanded( + child: Container( + height: 40, + margin: EdgeInsets.all(2), + child: TextButton( + onPressed: () async { + cameraMode = mode; setState(() {}); }, - child: Container( - margin: EdgeInsets.all(6), - width: active ? 70 : 55, - height: active ? 70 : 55, - alignment: Alignment.center, - child: Text( - "$p", - textAlign: TextAlign.center, - style: TextStyle( - fontWeight: active ? FontWeight.bold : null, - fontSize: active ? 16 : 14, - color: - active ? Colors.white : Colors.black), - ), - decoration: BoxDecoration( - color: active ? Colors.orange : Colors.white, - border: Border.all( - color: - active ? Colors.orange : Colors.white, - width: active ? 2 : 0), - shape: BoxShape.circle), + style: TextButton.styleFrom( + backgroundColor: Colors.black, + primary: Colors.black, + // shape: CircleBorder( + // side: BorderSide( + // color: Colors.white, width: 3)) ), - ); - }), - ), - ), - - SizedBox(height: 5), - - //change camera mode widget (mask/effect/filter) - Row( - children: List.generate(CameraMode.values.length, (p) { - CameraMode mode = CameraMode.values[p]; - bool active = cameraMode == mode; - - return Expanded( - child: Container( - height: 40, - margin: EdgeInsets.all(2), - child: TextButton( - onPressed: () async { - cameraMode = mode; - setState(() {}); - }, - style: TextButton.styleFrom( - backgroundColor: Colors.black, - primary: Colors.black, - // shape: CircleBorder( - // side: BorderSide( - // color: Colors.white, width: 3)) - ), - child: Text( - describeEnum(mode), - textAlign: TextAlign.center, - style: TextStyle( - fontWeight: active ? FontWeight.bold : null, - fontSize: active ? 16 : 14, - color: Colors.white - .withOpacity(active ? 1 : 0.6)), - ), + child: Text( + describeEnum(mode), + textAlign: TextAlign.center, + style: TextStyle( + fontWeight: active ? FontWeight.bold : null, + fontSize: active ? 16 : 14, + color: Colors.white + .withOpacity(active ? 1 : 0.6)), ), ), - ); - }), - ), + ), + ); + }), + ), - SizedBox(height: 5), + SizedBox(height: 5), - //change display mode widget (camera/image) - Row( - children: List.generate(DisplayMode.values.length, (p) { - DisplayMode mode = DisplayMode.values[p]; - bool active = displayMode == mode; - return Expanded( - child: Container( - height: 40, - margin: EdgeInsets.all(2), - child: TextButton( - onPressed: () async { - displayMode = mode; - deepArController.setDisplayMode( - mode: mode); - setState(() {}); - }, - style: TextButton.styleFrom( - backgroundColor: Colors.purple, - primary: Colors.black, - // shape: CircleBorder( - // side: BorderSide( - // color: Colors.white, width: 3)) - ), - child: Text( - describeEnum(mode), - textAlign: TextAlign.center, - style: TextStyle( - fontWeight: active ? FontWeight.bold : null, - fontSize: active ? 16 : 14, - color: Colors.white - .withOpacity(active ? 1 : 0.6)), - ), + //change display mode widget (camera/image) + Row( + children: List.generate(DisplayMode.values.length, (p) { + DisplayMode mode = DisplayMode.values[p]; + bool active = displayMode == mode; + return Expanded( + child: Container( + height: 40, + margin: EdgeInsets.all(2), + child: TextButton( + onPressed: () async { + displayMode = mode; + deepArController.setDisplayMode( + mode: mode); + setState(() {}); + }, + style: TextButton.styleFrom( + backgroundColor: Colors.purple, + primary: Colors.black, + // shape: CircleBorder( + // side: BorderSide( + // color: Colors.white, width: 3)) + ), + child: Text( + describeEnum(mode), + textAlign: TextAlign.center, + style: TextStyle( + fontWeight: active ? FontWeight.bold : null, + fontSize: active ? 16 : 14, + color: Colors.white + .withOpacity(active ? 1 : 0.6)), ), ), - ); - }), - ), - ], - ), + ), + ); + }), + ), + ], ), - ) - ], - ), + ), + ) + ], ), ); } - static Future _loadFile(String path, String name) async { - final ByteData data = await rootBundle.load(path); - Directory tempDir = await getTemporaryDirectory(); - File tempFile = File('${tempDir.path}/$name'); - await tempFile.writeAsBytes(data.buffer.asUint8List(), flush: true); - return tempFile; - } +// static Future _loadFile(String path, String name) async { +// final ByteData data = await rootBundle.load(path); +// Directory tempDir = await getTemporaryDirectory(); +// File tempFile = File('${tempDir.path}/$name'); +// await tempFile.writeAsBytes(data.buffer.asUint8List(), flush: true); +// return tempFile; +// } } + diff --git a/example/lib/video_preview_widget.dart b/example/lib/video_preview_widget.dart new file mode 100644 index 0000000..2c2683c --- /dev/null +++ b/example/lib/video_preview_widget.dart @@ -0,0 +1,57 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:video_player/video_player.dart'; + +class VideoPreviewWidget extends StatefulWidget { + final String videoPath; + const VideoPreviewWidget({Key? key, required this.videoPath}) : super(key: key); + + @override + State createState() => _VideoPreviewWidgetState(); +} + +class _VideoPreviewWidgetState extends State { + + VideoPlayerController? _controller; + + @override + initState() { + super.initState(); + print("PAAAATH"); + print(widget.videoPath); + _controller = VideoPlayerController.file( + // 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4', + File(widget.videoPath) + )..initialize().then((_) { + // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed. + setState(() {}); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child:_controller !=null && _controller!.value.isInitialized + ? AspectRatio( + aspectRatio: _controller!.value.aspectRatio, + child: VideoPlayer(_controller!), + ) + : Container(), + ), + floatingActionButton: FloatingActionButton( + onPressed: () { + setState(() { + _controller!.value.isPlaying + ? _controller!.pause() + : _controller!.play(); + }); + }, + child: Icon( + _controller!.value.isPlaying ? Icons.pause : Icons.play_arrow, + ), + ), + ); + } +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 18eb1a1..f0fb640 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: cupertino_icons: ^0.1.3 path_provider: ^2.0.5 image_picker: ^0.8.4+4 + video_player: ^2.4.5 dev_dependencies: flutter_test: From aac1cf696fb81b3d5e205d429aa74d08c7ed7334 Mon Sep 17 00:00:00 2001 From: Bidhan Rai Date: Thu, 23 Jun 2022 15:13:55 +0545 Subject: [PATCH 3/4] upgrade permission_handler, path_provider, flutter_plugin_android_lifecycle plugins --- pubspec.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index adb92cf..ea43d38 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,10 +18,10 @@ dependencies: # wakelock: ^0.5.0+2 # wakelock: ^0.5.6 # permission_handler: ^6.0.1 - permission_handler: ^8.2.5 + permission_handler: ^10.0.0 # flutter_device_type: ^0.4.0 - flutter_plugin_android_lifecycle: ^2.0.5 - path_provider: ^2.0.5 + flutter_plugin_android_lifecycle: ^2.0.6 + path_provider: ^2.0.11 dev_dependencies: From 417e182814e756fba3b2244e706616e1ead2ee2b Mon Sep 17 00:00:00 2001 From: Bidhan Rai Date: Thu, 23 Jun 2022 16:10:37 +0545 Subject: [PATCH 4/4] upgraded gradle version from 3.5.0 to 7.2.1 in example app --- example/android/app/build.gradle | 8 ++++---- example/android/build.gradle | 2 +- example/android/gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 123b530..28f555f 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -25,11 +25,8 @@ apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 29 + compileSdkVersion 33 - lintOptions { - disable 'InvalidPackage' - } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). @@ -48,6 +45,9 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + lint { + disable 'InvalidPackage' + } } flutter { diff --git a/example/android/build.gradle b/example/android/build.gradle index e0d7ae2..bd04753 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:7.2.1' } } diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 86fb97e..ca0f409 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip