Baseflow / screenrecorder

Flutter package which can be used to record flutter widgets
https://pub.dev/packages/screen_recorder
MIT License
64 stars 30 forks source link

screen recorder not working when camera is ON, i mean its showing white color. #10

Closed faisalmushtaq007 closed 2 years ago

faisalmushtaq007 commented 2 years ago

I tried to change the color but its not allowing me to use transparent color. Please help

ueman commented 2 years ago

Please add some more information and some example code. With the information you have given, there's no way to help you.

Please keep in mind, that this library is not yet considered stable, so expect to run into problems. There's a good chance, that setting a transparent color doesn't work. If you get it working, I would appreciate a PR.

faisalmushtaq007 commented 2 years ago

@ueman

 ScreenRecorder(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.height,
        controller: _screenRecorderController,
        child: Stack(
          children: [
            FutureBuilder<void>(
              future: _initializeControllerFuture,
              builder: (context, snapshot) {
                if (snapshot.connectionState == ConnectionState.done) {
                  if (pictureTaked) {
                    return SizedBox(
                      width: width,
                      height: height,
                      child: Transform(
                          alignment: Alignment.center,
                          child: FittedBox(
                            fit: BoxFit.cover,
                            child: Image.file(File(imagePath)),
                          ),
                          transform: Matrix4.rotationY(mirror)),
                    );
                  } else {
                    return Transform.scale(
                      scale: 1.0,
                      child: AspectRatio(
                        aspectRatio: MediaQuery.of(context).size.aspectRatio,
                        child: OverflowBox(
                          alignment: Alignment.center,
                          child: FittedBox(
                            fit: BoxFit.fitHeight,
                            child: SizedBox(
                              width: width,
                              height: width *
                                  _cameraService
                                      .cameraController.value.aspectRatio,
                              child: Stack(
                                fit: StackFit.expand,
                                children: <Widget>[
                                  CameraPreview(
                                      _cameraService.cameraController),
                                  CustomPaint(
                                    painter: FacePainter(
                                        face: faceDetected,
                                        imageSize: imageSize),
                                  ),
                                ],
                              ),
                            ),
                          ),
                        ),
                      ),
                    );
                  }
                } else {
                  return const Center(child: CircularProgressIndicator());
                }
              },
            ),
            CameraHeader(
              "Liveness Detection",
              onBackPressed: _onBackPressed,
            ),
            Align(
                alignment: Alignment.bottomCenter,
                child: Container(
                  width: double.infinity,
                  height: 200,
                  color: Colors.amber.withOpacity(0.2),
                  child: Center(
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        LinearProgressIndicator(
                          value: progress,
                          minHeight: 10,
                          valueColor:
                              AlwaysStoppedAnimation<Color>(Colors.greenAccent),
                          backgroundColor: Colors.amber,
                        ),
                        const SizedBox(height: 15),
                        Container(
                            padding: const EdgeInsets.symmetric(
                                vertical: 20, horizontal: 30),
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(10),
                                color: Colors.black87),
                            child: Column(
                              mainAxisSize: MainAxisSize.min,
                              children: [
                                Text(
                                  _status,
                                  textAlign: TextAlign.center,
                                  style: const TextStyle(
                                      fontSize: 22, color: Colors.yellowAccent),
                                ),
                                SizedBox(height: 10),
                                Text(
                                  _message,
                                  textAlign: TextAlign.center,
                                  style: const TextStyle(
                                      fontSize: 22, color: Colors.yellowAccent),
                                ),
                              ],
                            )),
                      ],
                    ),
                  ),
                )),
            recording
                ? Positioned(
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Container(
                          decoration: BoxDecoration(
                              shape: BoxShape.circle, color: Colors.redAccent),
                          height: 30,
                          width: 20,
                        ),
                        ShaderMask(
                            shaderCallback: (shader) {
                              return LinearGradient(
                                colors: [
                                  Helper.primary,
                                  Colors.green,
                                  Helper.secondaryRed
                                ],
                                tileMode: TileMode.mirror,
                              ).createShader(shader);
                            },
                            child: Text(
                              "Recording...",
                              style: Theme.of(context)
                                  .textTheme
                                  .caption
                                  .copyWith(color: Colors.white),
                            )),
                      ],
                    ),
                    top: MediaQuery.of(context).size.height * 0.1,
                    right: 0,
                  )
                : SizedBox(),
          ],
        ),
      ),
faisalmushtaq007 commented 2 years ago

@ueman Actually i am working on liveness detection functionality and one problem that i am facing is that as i use the imageStream method of camera plugin, i cant record the video. But for my project i need to record it. So as a way around i used your package, but camera specific screen is showing white

ueman commented 2 years ago

Ah I see, as this plugin can't record whatever is shown in PlatformViews (such as webviews, camera previews, maps, ...). This is a limitation of the Flutter framework itself, so there's nothing I can do about that. There are probably plugins which support it by using native functionality.

faisalmushtaq007 commented 2 years ago

@ueman do you have any idea of such packages. Please i am stuck with this thing

ueman commented 2 years ago

Unfortunately, I don't know any.