endmr11 / ed_screen_recorder

Screen recorder plugin for Flutter. Supports IOS and Android devices.
MIT License
26 stars 36 forks source link

screen recording audio issue & file path. #32

Open jaish702 opened 2 years ago

jaish702 commented 2 years ago

I am getting an issue while start screen recording with audio. but if I am starting screen recording without audio no error is coming. my second issue is not able to see my videos in gallery. and plz upgrade the SDK level to 33. and also upgrade hbrecorder dependence from 2.0.4 to 2.0.5. i am getting all this issue while copying your example and run it .

import 'dart:async'; import 'dart:developer'; import 'dart:io';

import 'package:ed_screen_recorder/ed_screen_recorder.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:path_provider/path_provider.dart';

void main() { runApp(const MyApp()); }

class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key);

@override State createState() => _MyAppState(); }

class _MyAppState extends State { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData.dark(), debugShowCheckedModeBanner: false, home: const HomePage(), ); } }

class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key);

@override State createState() => _HomePageState(); }

class _HomePageState extends State { EdScreenRecorder? screenRecorder; Map<String, dynamic>? _response; bool inProgress = false;

@override void initState() { super.initState(); screenRecorder = EdScreenRecorder(); }

Future startRecord({required String fileName}) async { Directory? tempDir = await getApplicationDocumentsDirectory(); String? tempPath = tempDir.path; try { var startResponse = await screenRecorder?.startRecordScreen( fileName: "Eren", //Optional. It will save the video there when you give the file path with whatever you want. //If you leave it blank, the Android operating system will save it to the gallery. dirPathToSave: tempPath, audioEnable: false, ); setState(() { _response = startResponse; }); try { screenRecorder?.watcher?.events.listen( (event) { log(event.type.toString(), name: "Event: "); }, onError: (e) => kDebugMode ? debugPrint('ERROR ON STREAM: $e') : null, onDone: () => kDebugMode ? debugPrint('Watcher closed!') : null, ); } catch (e) { kDebugMode ? debugPrint('ERROR WAITING FOR READY: $e') : null; } } on PlatformException { kDebugMode ? debugPrint("Error: An error occurred while starting the recording!") : null; } }

Future stopRecord() async { try { var stopResponse = await screenRecorder?.stopRecord(); setState(() { _response = stopResponse; }); } on PlatformException { kDebugMode ? debugPrint("Error: An error occurred while stopping recording.") : null; } }

Future pauseRecord() async { try { await screenRecorder?.pauseRecord(); } on PlatformException { kDebugMode ? debugPrint("Error: An error occurred while pause recording.") : null; } }

Future resumeRecord() async { try { await screenRecorder?.resumeRecord(); } on PlatformException { kDebugMode ? debugPrint("Error: An error occurred while resume recording.") : null; } }

@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Screen Recording Debug"), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("File: ${(_response?['file'] as File?)?.path}"), Text("Status: ${(_response?['success']).toString()}"), Text("Event: ${_response?['eventname']}"), Text("Progress: ${(_response?['progressing']).toString()}"), Text("Message: ${_response?['message']}"), Text("Video Hash: ${_response?['videohash']}"), Text("Start Date: ${(_response?['startdate']).toString()}"), Text("End Date: ${(_response?['enddate']).toString()}"), ElevatedButton(onPressed: () => startRecord(fileName: "eren"), child: const Text('START RECORD')), ElevatedButton(onPressed: () => resumeRecord(), child: const Text('RESUME RECORD')), ElevatedButton(onPressed: () => pauseRecord(), child: const Text('PAUSE RECORD')), ElevatedButton(onPressed: () => stopRecord(), child: const Text('STOP RECORD')), ], ), ), ); } }

thank you @endmr11

Cevocey commented 1 year ago

try { var status = await Permission.microphone.request(); var startResponse = await screenRecorder?.startRecordScreen( fileName: "Kayit", //Optional. It will save the video there when you give the file path with whatever you want. //If you leave it blank, the Android operating system will save it to the gallery. dirPathToSave: null, audioEnable: false, );

As it says in the comment line dirPathToSave: null, if you do it will save it to the gallery. I couldn't find the audio recording problem either.

endmr11 commented 1 year ago

Version 0.0.13 has been released. Could you please check again and report back to me?