LJaraCastillo / native_video_view

A video player widget displayed using the platform native player (VideoView in Android and AVPlayer in iOS).
MIT License
37 stars 30 forks source link

does not work with recorded video #24

Open Rockus-com opened 2 years ago

Rockus-com commented 2 years ago

Trying to record video with camera flutter package and then play, but keep getting this error

Launching lib\main.dart on Android SDK built for x86 in debug mode...
√  Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:57893/g6S1Gv_h-AU=/ws
I/CameraManagerGlobal(14959): Connecting to camera service
W/Camera  (14959): The selected imageFormatGroup is not supported by Android. Defaulting to yuv420
I/Camera  (14959): startPreview
I/Camera  (14959): CameraCaptureSession onConfigured
I/Camera  (14959): Updating builder settings
D/Camera  (14959): Updating builder with feature: ExposureLockFeature
D/Camera  (14959): Updating builder with feature: ExposurePointFeature
D/Camera  (14959): Updating builder with feature: ZoomLevelFeature
D/Camera  (14959): Updating builder with feature: AutoFocusFeature
D/Camera  (14959): Updating builder with feature: NoiseReductionFeature
I/Camera  (14959): updateNoiseReduction | currentSetting: fast
D/Camera  (14959): Updating builder with feature: FocusPointFeature
D/Camera  (14959): Updating builder with feature: ResolutionFeature
D/Camera  (14959): Updating builder with feature: SensorOrientationFeature
D/Camera  (14959): Updating builder with feature: FlashFeature
D/Camera  (14959): Updating builder with feature: ExposureOffsetFeature
D/Camera  (14959): Updating builder with feature: FpsRangeFeature
I/Camera  (14959): refreshPreviewCaptureSession
W/Gralloc4(14959): allocator 3.x is not supported
I/Camera  (14959): prepareMediaRecorder
I/Camera  (14959): CameraCaptureSession onConfigured
I/Camera  (14959): Updating builder settings
D/Camera  (14959): Updating builder with feature: ExposureLockFeature
D/Camera  (14959): Updating builder with feature: ExposurePointFeature
D/Camera  (14959): Updating builder with feature: ZoomLevelFeature
D/Camera  (14959): Updating builder with feature: AutoFocusFeature
D/Camera  (14959): Updating builder with feature: NoiseReductionFeature
I/Camera  (14959): updateNoiseReduction | currentSetting: fast
D/Camera  (14959): Updating builder with feature: FocusPointFeature
D/Camera  (14959): Updating builder with feature: ResolutionFeature
D/Camera  (14959): Updating builder with feature: SensorOrientationFeature
D/Camera  (14959): Updating builder with feature: FlashFeature
D/Camera  (14959): Updating builder with feature: ExposureOffsetFeature
D/Camera  (14959): Updating builder with feature: FpsRangeFeature
I/Camera  (14959): refreshPreviewCaptureSession
I/Camera  (14959): CameraCaptureSession onClosed
I/Camera  (14959): startPreview
I/Camera  (14959): CameraCaptureSession onClosed
I/Camera  (14959): CameraCaptureSession onConfigured
I/Camera  (14959): Updating builder settings
D/Camera  (14959): Updating builder with feature: ExposureLockFeature
D/Camera  (14959): Updating builder with feature: ExposurePointFeature
D/Camera  (14959): Updating builder with feature: ZoomLevelFeature
D/Camera  (14959): Updating builder with feature: AutoFocusFeature
D/Camera  (14959): Updating builder with feature: NoiseReductionFeature
I/Camera  (14959): updateNoiseReduction | currentSetting: fast
D/Camera  (14959): Updating builder with feature: FocusPointFeature
D/Camera  (14959): Updating builder with feature: ResolutionFeature
D/Camera  (14959): Updating builder with feature: SensorOrientationFeature
D/Camera  (14959): Updating builder with feature: FlashFeature
D/Camera  (14959): Updating builder with feature: ExposureOffsetFeature
D/Camera  (14959): Updating builder with feature: FpsRangeFeature
I/Camera  (14959): refreshPreviewCaptureSession
I/ExoPlayerImpl(14959): Init 8d11d72 [ExoPlayerLib/2.18.1] [generic_x86, Android SDK built for x86, unknown, 30]
W/le.flutter_cha(14959): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
I/TetheringManager(14959): registerTetheringEventCallback:com.example.flutter_chat
I/VideoCapabilities(14959): Unsupported profile 4 for video/mp4v-es
I/OMXClient(14959): IOmx service obtained
D/SurfaceUtils(14959): connecting to surface 0xb812f3b8, reason connectToSurface
I/MediaCodec(14959): [OMX.android.goldfish.h264.decoder] setting surface generation to 15318017
D/SurfaceUtils(14959): disconnecting from surface 0xb812f3b8, reason connectToSurface(reconnect)
D/SurfaceUtils(14959): connecting to surface 0xb812f3b8, reason connectToSurface(reconnect)
E/ACodec  (14959): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
I/ACodec  (14959): codec does not support config priority (err -1010)
D/SurfaceUtils(14959): disconnecting from surface 0xb812f3b8, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils(14959): connecting to surface 0xb812f3b8, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils(14959): set up nativeWindow 0xb812f3b8 for 1280x720, color 0x13, rotation 90, usage 0x1002900
W/ACodec  (14959): [OMX.android.goldfish.h264.decoder] BAD CODEC: Output format changed unexpectedly from (diff) AMessage(what = 0x00000000) = {
W/ACodec  (14959):       int32_t color-standard = 1
W/ACodec  (14959):     } to (diff) AMessage(what = 0x00000000) = {
W/ACodec  (14959):       int32_t color-standard = 130817
W/ACodec  (14959):     }
D/CCodec  (14959): allocate(c2.android.amrnb.decoder)
I/Codec2Client(14959): Available Codec2 services: "software"
I/CCodec  (14959): Created component [c2.android.amrnb.decoder]
D/CCodecConfig(14959): read media type: audio/3gpp
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: algo.buffers.max-count.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: output.subscribed-indices.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: input.buffers.allocator-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: output.buffers.allocator-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: algo.buffers.allocator-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: output.buffers.pool-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: algo.buffers.pool-ids.values
I/CCodecConfig(14959): query failed after returning 7 values (BAD_INDEX)
D/CCodecConfig(14959): c2 config diff is Dict {
D/CCodecConfig(14959):   c2::u32 coded.bitrate.value = 4750
D/CCodecConfig(14959):   c2::u32 input.buffers.max-size.value = 8192
D/CCodecConfig(14959):   c2::u32 input.delay.value = 0
D/CCodecConfig(14959):   string input.media-type.value = "audio/3gpp"
D/CCodecConfig(14959):   string output.media-type.value = "audio/raw"
D/CCodecConfig(14959):   c2::u32 raw.channel-count.value = 1
D/CCodecConfig(14959):   c2::u32 raw.sample-rate.value = 8000
D/CCodecConfig(14959): }
D/CCodec  (14959): [c2.android.amrnb.decoder] buffers are bound to CCodec for this session
D/CCodecConfig(14959): no c2 equivalents for flags
D/CCodecConfig(14959): config failed => CORRUPTED
W/Codec2Client(14959): query -- param skipped: index = 1107298332.
D/CCodec  (14959): client requested max input size 62, which is smaller than what component recommended (8192); overriding with component recommendation.
W/CCodec  (14959): This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
D/CCodec  (14959): setup formats input: AMessage(what = 0x00000000) = {
D/CCodec  (14959):   int32_t channel-count = 1
D/CCodec  (14959):   int32_t max-input-size = 8192
D/CCodec  (14959):   string mime = "audio/3gpp"
D/CCodec  (14959):   int32_t sample-rate = 8000
D/CCodec  (14959): } and output: AMessage(what = 0x00000000) = {
D/CCodec  (14959):   int32_t channel-count = 1
D/CCodec  (14959):   string mime = "audio/raw"
D/CCodec  (14959):   int32_t sample-rate = 8000
D/CCodec  (14959): }
W/Codec2Client(14959): query -- param skipped: index = 1342179345.
W/Codec2Client(14959): query -- param skipped: index = 2415921170.
E/FMQ     (14959): grantorIdx must be less than 3
E/FMQ     (14959): grantorIdx must be less than 3
D/CCodecBufferChannel(14959): [c2.android.amrnb.decoder#864] Created input block pool with allocatorID 16 => poolID 17 - OK (0)
I/CCodecBufferChannel(14959): [c2.android.amrnb.decoder#864] Created output block pool with allocatorID 16 => poolID 80 - OK
D/CCodecBufferChannel(14959): [c2.android.amrnb.decoder#864] Configured output block pool ids 80 => OK
E/ion     (14959): ioctl c0044901 failed with code -1: Inappropriate ioctl for device
E/FMQ     (14959): grantorIdx must be less than 3
E/FMQ     (14959): grantorIdx must be less than 3
I/ExoPlayerImpl(14959): Init baf187a [ExoPlayerLib/2.18.1] [generic_x86, Android SDK built for x86, unknown, 30]
D/AudioTrack(14959): getTimestamp_l(131): device stall time corrected using current time 23148773865850
I/OMXClient(14959): IOmx service obtained
D/SurfaceUtils(14959): connecting to surface 0xb8135878, reason connectToSurface
I/MediaCodec(14959): [OMX.android.goldfish.h264.decoder] setting surface generation to 15318018
D/SurfaceUtils(14959): disconnecting from surface 0xb8135878, reason connectToSurface(reconnect)
D/SurfaceUtils(14959): connecting to surface 0xb8135878, reason connectToSurface(reconnect)
E/ACodec  (14959): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
I/ACodec  (14959): codec does not support config priority (err -1010)
D/SurfaceUtils(14959): disconnecting from surface 0xb8135878, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils(14959): connecting to surface 0xb8135878, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils(14959): set up nativeWindow 0xb8135878 for 1280x720, color 0x13, rotation 90, usage 0x1002900
D/CCodec  (14959): allocate(c2.android.amrnb.decoder)
I/CCodec  (14959): Created component [c2.android.amrnb.decoder]
D/CCodecConfig(14959): read media type: audio/3gpp
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: algo.buffers.max-count.values
W/ACodec  (14959): [OMX.android.goldfish.h264.decoder] BAD CODEC: Output format changed unexpectedly from (diff) AMessage(what = 0x00000000) = {
W/ACodec  (14959):       int32_t color-standard = 1
W/ACodec  (14959):     } to (diff) AMessage(what = 0x00000000) = {
W/ACodec  (14959):       int32_t color-standard = 130817
W/ACodec  (14959):     }
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: output.subscribed-indices.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: input.buffers.allocator-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: output.buffers.allocator-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: algo.buffers.allocator-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: output.buffers.pool-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: algo.buffers.pool-ids.values
I/CCodecConfig(14959): query failed after returning 7 values (BAD_INDEX)
D/CCodecConfig(14959): c2 config diff is Dict {
D/CCodecConfig(14959):   c2::u32 coded.bitrate.value = 4750
D/CCodecConfig(14959):   c2::u32 input.buffers.max-size.value = 8192
D/CCodecConfig(14959):   c2::u32 input.delay.value = 0
D/CCodecConfig(14959):   string input.media-type.value = "audio/3gpp"
D/CCodecConfig(14959):   string output.media-type.value = "audio/raw"
D/CCodecConfig(14959):   c2::u32 raw.channel-count.value = 1
D/CCodecConfig(14959):   c2::u32 raw.sample-rate.value = 8000
D/CCodecConfig(14959): }
D/CCodec  (14959): [c2.android.amrnb.decoder] buffers are bound to CCodec for this session
D/CCodecConfig(14959): no c2 equivalents for flags
D/CCodecConfig(14959): config failed => CORRUPTED
W/Codec2Client(14959): query -- param skipped: index = 1107298332.
D/CCodec  (14959): client requested max input size 62, which is smaller than what component recommended (8192); overriding with component recommendation.
W/CCodec  (14959): This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
D/CCodec  (14959): setup formats input: AMessage(what = 0x00000000) = {
D/CCodec  (14959):   int32_t channel-count = 1
D/CCodec  (14959):   int32_t max-input-size = 8192
D/CCodec  (14959):   string mime = "audio/3gpp"
D/CCodec  (14959):   int32_t sample-rate = 8000
D/CCodec  (14959): } and output: AMessage(what = 0x00000000) = {
D/CCodec  (14959):   int32_t channel-count = 1
D/CCodec  (14959):   string mime = "audio/raw"
D/CCodec  (14959):   int32_t sample-rate = 8000
D/CCodec  (14959): }
W/Codec2Client(14959): query -- param skipped: index = 1342179345.
W/Codec2Client(14959): query -- param skipped: index = 2415921170.
E/FMQ     (14959): grantorIdx must be less than 3
E/FMQ     (14959): grantorIdx must be less than 3
D/CCodecBufferChannel(14959): [c2.android.amrnb.decoder#515] Created input block pool with allocatorID 16 => poolID 18 - OK (0)
I/CCodecBufferChannel(14959): [c2.android.amrnb.decoder#515] Created output block pool with allocatorID 16 => poolID 81 - OK
D/CCodecBufferChannel(14959): [c2.android.amrnb.decoder#515] Configured output block pool ids 81 => OK
E/FMQ     (14959): grantorIdx must be less than 3
E/FMQ     (14959): grantorIdx must be less than 3
D/AudioTrack(14959): stop(131): called with 16800 frames delivered
D/BufferPoolAccessor2.0(14959): bufferpool2 0xec2ce5a8 : 4(32768 size) total buffers - 4(32768 size) used buffers - 0/5 (recycle/alloc) - 11/210 (fetch/transfer)
D/BufferPoolAccessor2.0(14959): evictor expired: 1, evicted: 1
D/BufferPoolAccessor2.0(14959): bufferpool2 0xec2cd4a8 : 5(40960 size) total buffers - 4(32768 size) used buffers - 0/5 (recycle/alloc) - 4/38 (fetch/transfer)
D/BufferPoolAccessor2.0(14959): evictor expired: 1, evicted: 1
D/AudioManager(14959): dispatching onAudioFocusChange(-1) to android.media.AudioManager@7a89a0fcom.google.android.exoplayer2.AudioFocusManager$AudioFocusListener@8545a9c
I/ExoPlayerImpl(14959): Init 246121b [ExoPlayerLib/2.18.1] [generic_x86, Android SDK built for x86, unknown, 30]
D/AudioTrack(14959): getTimestamp_l(132): device stall time corrected using current time 23158805294650
I/OMXClient(14959): IOmx service obtained
D/SurfaceUtils(14959): connecting to surface 0xe6f179e8, reason connectToSurface
I/MediaCodec(14959): [OMX.android.goldfish.h264.decoder] setting surface generation to 15318019
D/SurfaceUtils(14959): disconnecting from surface 0xe6f179e8, reason connectToSurface(reconnect)
D/SurfaceUtils(14959): connecting to surface 0xe6f179e8, reason connectToSurface(reconnect)
E/ACodec  (14959): [OMX.android.goldfish.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
I/ACodec  (14959): codec does not support config priority (err -1010)
D/BufferPoolAccessor2.0(14959): bufferpool2 0xec2ce5a8 : 4(32768 size) total buffers - 4(32768 size) used buffers - 0/5 (recycle/alloc) - 11/210 (fetch/transfer)
D/SurfaceUtils(14959): disconnecting from surface 0xe6f179e8, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils(14959): connecting to surface 0xe6f179e8, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils(14959): set up nativeWindow 0xe6f179e8 for 1280x720, color 0x13, rotation 90, usage 0x1002900
W/ACodec  (14959): [OMX.android.goldfish.h264.decoder] BAD CODEC: Output format changed unexpectedly from (diff) AMessage(what = 0x00000000) = {
W/ACodec  (14959):       int32_t color-standard = 1
W/ACodec  (14959):     } to (diff) AMessage(what = 0x00000000) = {
W/ACodec  (14959):       int32_t color-standard = 130817
W/ACodec  (14959):     }
D/CCodec  (14959): allocate(c2.android.amrnb.decoder)
I/CCodec  (14959): Created component [c2.android.amrnb.decoder]
D/CCodecConfig(14959): read media type: audio/3gpp
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: algo.buffers.max-count.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: output.subscribed-indices.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: input.buffers.allocator-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: output.buffers.allocator-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: algo.buffers.allocator-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: output.buffers.pool-ids.values
D/ReflectedParamUpdater(14959): extent() != 1 for single value type: algo.buffers.pool-ids.values
I/CCodecConfig(14959): query failed after returning 7 values (BAD_INDEX)
D/CCodecConfig(14959): c2 config diff is Dict {
D/CCodecConfig(14959):   c2::u32 coded.bitrate.value = 4750
D/CCodecConfig(14959):   c2::u32 input.buffers.max-size.value = 8192
D/CCodecConfig(14959):   c2::u32 input.delay.value = 0
D/CCodecConfig(14959):   string input.media-type.value = "audio/3gpp"
D/CCodecConfig(14959):   string output.media-type.value = "audio/raw"
D/CCodecConfig(14959):   c2::u32 raw.channel-count.value = 1
D/CCodecConfig(14959):   c2::u32 raw.sample-rate.value = 8000
D/CCodecConfig(14959): }
D/CCodec  (14959): [c2.android.amrnb.decoder] buffers are bound to CCodec for this session
D/CCodecConfig(14959): no c2 equivalents for flags
D/CCodecConfig(14959): config failed => CORRUPTED
W/Codec2Client(14959): query -- param skipped: index = 1107298332.
D/CCodec  (14959): client requested max input size 62, which is smaller than what component recommended (8192); overriding with component recommendation.
W/CCodec  (14959): This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
D/CCodec  (14959): setup formats input: AMessage(what = 0x00000000) = {
D/CCodec  (14959):   int32_t channel-count = 1
D/CCodec  (14959):   int32_t max-input-size = 8192
D/CCodec  (14959):   string mime = "audio/3gpp"
D/CCodec  (14959):   int32_t sample-rate = 8000
D/CCodec  (14959): } and output: AMessage(what = 0x00000000) = {
D/CCodec  (14959):   int32_t channel-count = 1
D/CCodec  (14959):   string mime = "audio/raw"
D/CCodec  (14959):   int32_t sample-rate = 8000
D/CCodec  (14959): }
W/Codec2Client(14959): query -- param skipped: index = 1342179345.
W/Codec2Client(14959): query -- param skipped: index = 2415921170.
E/FMQ     (14959): grantorIdx must be less than 3
E/FMQ     (14959): grantorIdx must be less than 3
D/CCodecBufferChannel(14959): [c2.android.amrnb.decoder#354] Created input block pool with allocatorID 16 => poolID 19 - OK (0)
I/CCodecBufferChannel(14959): [c2.android.amrnb.decoder#354] Created output block pool with allocatorID 16 => poolID 82 - OK
D/CCodecBufferChannel(14959): [c2.android.amrnb.decoder#354] Configured output block pool ids 82 => OK
E/FMQ     (14959): grantorIdx must be less than 3
E/FMQ     (14959): grantorIdx must be less than 3
D/BufferPoolAccessor2.0(14959): bufferpool2 0xec2cd4a8 : 4(32768 size) total buffers - 4(32768 size) used buffers - 0/5 (recycle/alloc) - 11/121 (fetch/transfer)
D/AudioTrack(14959): stop(132): called with 16800 frames delivered
D/BufferPoolAccessor2.0(14959): bufferpool2 0xec2cba18 : 5(40960 size) total buffers - 4(32768 size) used buffers - 0/5 (recycle/alloc) - 4/38 (fetch/transfer)
D/BufferPoolAccessor2.0(14959): evictor expired: 1, evicted: 1
Lost connection to device.
Exited (sigterm)

This is my code:

CameraScreen.dart

import 'dart:io';

import 'package:camera/camera.dart';
import 'package:chto/Screens/CameraView.dart';
import 'package:chto/Screens/VideoView.dart';
import 'package:flutter/material.dart';
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';

List<CameraDescription> cameras = [];

class CameraScreen extends StatefulWidget {
  const CameraScreen({super.key});

  @override
  State<CameraScreen> createState() => _CameraScreenState();
}

class _CameraScreenState extends State<CameraScreen> {
  late CameraController _cameraController;

  late Future<void> cameravalue;
  bool isRecording = false;
  String videopath = '';

  @override
  void initState() {
    super.initState();
    _cameraController = CameraController(cameras[0], ResolutionPreset.high);
    cameravalue = _cameraController.initialize();
  }

  @override
  void dispose() {
    super.dispose();
    _cameraController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          FutureBuilder(
              future: cameravalue,
              builder: (context, snapshot) {
                if (snapshot.connectionState == ConnectionState.done) {
                  return CameraPreview(_cameraController);
                } else {
                  return Center(
                    child: CircularProgressIndicator(),
                  );
                }
              }),
          Positioned(
            bottom: 0,
            child: Container(
              height: 100,
              color: Colors.black,
              padding: EdgeInsets.only(top: 5, bottom: 5),
              width: MediaQuery.of(context).size.width,
              child: Column(
                children: [
                  Row(
                    mainAxisSize: MainAxisSize.max,
                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                    children: [
                      IconButton(
                        onPressed: () {},
                        icon: Icon(
                          Icons.flash_off,
                          color: Colors.white,
                          size: 28,
                        ),
                      ),
                      GestureDetector(
                        onLongPress: () async {
                          // final path = join(
                          //     (await getTemporaryDirectory()).path,
                          //     "${DateTime.now()}.mp4");
                          await _cameraController.prepareForVideoRecording();
                          await _cameraController.startVideoRecording();
                          setState(() {
                            isRecording = true;
                          });
                        },
                        onLongPressUp: () async {
                          final video =
                              await _cameraController.stopVideoRecording();
                          setState(() {
                            isRecording = false;
                            videopath = video.path;
                          });
                          Navigator.push(
                              context,
                              MaterialPageRoute(
                                  builder: (builder) => VideoViewPage(
                                        path: videopath,
                                      )));
                        },
                        onTap: () {
                          if (!isRecording) takePhoto(context);
                        },
                        child: isRecording
                            ? Icon(
                                Icons.radio_button_on,
                                color: Colors.red,
                                size: 65,
                              )
                            : Icon(
                                Icons.panorama_fish_eye,
                                color: Colors.white,
                                size: 60,
                              ),
                      ),
                      IconButton(
                        onPressed: () {},
                        icon: Icon(
                          Icons.flip_camera_ios,
                          color: Colors.white,
                          size: 28,
                        ),
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 4,
                  ),
                  Text(
                    "Коснись для фото, держи для видео",
                    style: TextStyle(color: Colors.white),
                    textAlign: TextAlign.center,
                  )
                ],
              ),
            ),
          )
        ],
      ),
    );
  }

  void takePhoto(BuildContext context) async {
    final path =
        join((await getTemporaryDirectory()).path, "${DateTime.now()}.png");
    final image = await _cameraController.takePicture();
    Navigator.push(
      context,
      MaterialPageRoute(builder: (builder) => CameraViewPage(path: image.path)),
    );
  }
}

VideoView.dart

// import 'dart:html';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

class VideoViewPage extends StatefulWidget {
  const VideoViewPage({super.key, required this.path});
  final String path;

  @override
  State<VideoViewPage> createState() => _VideoViewPageState();
}

class _VideoViewPageState extends State<VideoViewPage> {
  late VideoPlayerController _controller;
  @override
  void initState() {
    super.initState();
  }

  Future _initVideoPlayer() async {
    _controller = VideoPlayerController.file(File(widget.path));
    await _controller.initialize();
    await _controller.setLooping(false);
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      appBar: AppBar(
        backgroundColor: Colors.black,
        actions: [
          IconButton(
            onPressed: () {},
            icon: Icon(
              Icons.crop_rotate,
              size: 27,
            ),
          ),
          IconButton(
            onPressed: () {},
            icon: Icon(
              Icons.emoji_emotions_outlined,
              size: 27,
            ),
          ),
          IconButton(
            onPressed: () {},
            icon: Icon(
              Icons.title,
              size: 27,
            ),
          ),
          IconButton(
            onPressed: () {},
            icon: Icon(
              Icons.edit,
              size: 27,
            ),
          ),
        ],
      ),
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        child: Stack(
          children: [
            Container(
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height - 150,
              child: FutureBuilder(
                future: _initVideoPlayer(),
                builder: (context, state) {
                  if (state.connectionState == ConnectionState.waiting) {
                    return const Center(child: CircularProgressIndicator());
                  } else {
                    return AspectRatio(
                      aspectRatio: _controller.value.aspectRatio,
                      child: VideoPlayer(_controller),
                    );
                  }
                },
              ),
            ),
            Positioned(
              bottom: 0,
              child: Container(
                color: Colors.black,
                width: MediaQuery.of(context).size.width,
                padding: EdgeInsets.symmetric(vertical: 5, horizontal: 8),
                child: TextFormField(
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 17,
                  ),
                  maxLines: 6,
                  minLines: 1,
                  decoration: InputDecoration(
                      border: InputBorder.none,
                      hintText: "Добавтье подпись",
                      prefixIcon: Icon(
                        Icons.add_photo_alternate,
                        color: Colors.white,
                        size: 27,
                      ),
                      hintStyle: TextStyle(
                        color: Colors.white,
                        fontSize: 17,
                      ),
                      suffixIcon: CircleAvatar(
                        radius: 27,
                        backgroundColor: Colors.tealAccent[700],
                        child: Icon(
                          Icons.check,
                          color: Colors.white,
                          size: 27,
                        ),
                      )),
                ),
              ),
            ),
            Align(
              alignment: Alignment.center,
              child: InkWell(
                onTap: () {
                  setState(() {
                    _controller.value.isPlaying
                        ? _controller.pause()
                        : _controller.play();
                  });
                },
                child: CircleAvatar(
                  radius: 33,
                  backgroundColor: Colors.black38,
                  child: Icon(
                    _controller.value.isPlaying
                        ? Icons.pause
                        : Icons.play_arrow,
                    color: Colors.white,
                    size: 50,
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
jdevp commented 1 year ago

Hi, You posted at the place. You are using Video_Player package. This is native_video_view package. I'm curious if you have found a solution. I'm having issues with both packages on recorded video.