januwA / flutter_video_box

flutter_video_box
MIT License
22 stars 12 forks source link

E/flutter (16773): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method setAccelerationSamplingPeriod on channel dev.fluttercommunity.plus/sensors/method) E/flutter (16773): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:320:7) #38

Open fuedgabriel opened 9 months ago

fuedgabriel commented 9 months ago

Error output below

D/AudioManager(16773): getStreamVolume isRestricted mode = 0
E/flutter (16773): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method setAccelerationSamplingPeriod on channel dev.fluttercommunity.plus/sensors/method)
E/flutter (16773): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:320:7)
E/flutter (16773): <asynchronous suspension>
E/flutter (16773): 
I/OMXClient(16773): IOmx service obtained
D/SurfaceUtils(16773): connecting to surface 0x7321703010, reason connectToSurface
I/MediaCodec(16773): [OMX.qcom.video.decoder.avc] setting surface generation to 17175570
D/SurfaceUtils(16773): disconnecting from surface 0x7321703010, reason connectToSurface(reconnect)
D/SurfaceUtils(16773): connecting to surface 0x7321703010, reason connectToSurface(reconnect)
I/ExtendedACodec(16773): setupVideoDecoder()
I/ExtendedACodec(16773): Decoder will be in frame by frame mode
D/SurfaceUtils(16773): set up nativeWindow 0x7321703010 for 480x270, color 0x7fa30c06, rotation 0, usage 0x20002900
I/OMXClient(16773): IOmx service obtained
I/ACodec  (16773): codec does not support config priority (err -2147483648)
I/ACodec  (16773): codec does not support config priority (err -2147483648)
I/ACodec  (16773): codec does not support config operating rate (err -2147483648)
W/ExtendedACodec(16773): Failed to get extension for extradata parameter
D/SurfaceUtils(16773): set up nativeWindow 0x7321703010 for 480x272, color 0x7fa30c06, rotation 0, usage 0x20002900
D/AudioTrack(16773): get packages (com.animese.animese) for calling UID 10377
D/AudioTrack(16773): set(): Force removing AUDIO_OUTPUT_FLAG_RAW
I/flutter (16773): true
I/flutter (16773): null
W/BpBinder(16773): Slow Binder: BpBinder transact took 204 ms, interface=android.media.IAudioTrack, code=2 oneway=false
D/AudioTrack(16773): getTimestamp_l(16835): device stall time corrected using current time 642885388362929
D/ViewRootImpl(16773): [TouchInput][ViewRootImpl] MotionEvent { action=ACTION_DOWN, id[0]=0, pointerCount=1, eventTime=642892805, downTime=642892805 } moveCount:0
D/ViewRootImpl(16773): [TouchInput][ViewRootImpl] MotionEvent { action=ACTION_UP, id[0]=0, pointerCount=1, eventTime=642892863, downTime=642892805 } moveCount:0
D/ViewRootImpl(16773): [TouchInput][ViewRootImpl] MotionEvent { action=ACTION_DOWN, id[0]=0, pointerCount=1, eventTime=642893718, downTime=642893718 } moveCount:0
D/ViewRootImpl(16773): [TouchInput][ViewRootImpl] MotionEvent { action=ACTION_UP, id[0]=0, pointerCount=1, eventTime=642893792, downTime=642893718 } moveCount:0

Code

import 'package:animese/colors.dart';
import 'package:flutter/material.dart';
import 'package:video_box/video_box.dart';

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

  @override
  State<PlayerVideo> createState() => _PlayerVideoState();
}

class _PlayerVideoState extends State<PlayerVideo> {
  late VideoController vc;
  ScrollController controller = ScrollController();

  @override
  void initState() {
    super.initState();
    _init();
  }

  void _init() async {
    vc = VideoController(
      // ignore: deprecated_member_use
      source: VideoPlayerController.network('https://edisciplinas.usp.br/pluginfile.php/5196097/mod_resource/content/1/Teste.mp4'),
      autoplay: true,
    )
      ..initialize().then((e) {
        // ignore: avoid_print
        print(e);
        // if (e != null) {
        //   print('[video box init] error: ' + e.message);
        // } else {
        //   print('[video box init] success');
        // }
      })
      ..addListener(() {
        if (vc.videoCtrl.value.isBuffering) {
          // ignore: avoid_print
          print('==============================');
          // ignore: avoid_print
          print('isBuffering');
          // ignore: avoid_print
          print('==============================');
        }
      });
  }

  @override
  void dispose() {
    vc.dispose();
    super.dispose();
  }
  bool swap = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        controller: controller,
        children: <Widget>[
          AspectRatio(
            aspectRatio: 16 / 9,
            child: VideoBox(
              controller: vc,
              children: <Widget>[
                // VideoBar(vc: vc),
                 Align(
                  alignment: const Alignment(-0.9, -0.9),
                  child: Row(
                    children: [
                      const SizedBox(width: 10,),
                      IconButton(
                        icon: const Icon(Icons.arrow_back, color: Colors.white,),
                        onPressed: () {
                          Navigator.pop(context);
                        },
                      ),
                      const Image(
                        image: AssetImage('assets/images/logo.png'),
                        width: 30,
                        opacity: AlwaysStoppedAnimation(.6),
                      ),
                      const SizedBox(width: 10,),
                      const Text(
                        'video box',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 18,
                        ),
                      ),
                    ],
                  )
                ),
                Align(
                  alignment: const Alignment(-0.5, 0),
                  child: IconButton(
                    iconSize: VideoBox.centerIconSize,
                    disabledColor: Colors.white60,
                    icon: const Icon(Icons.skip_previous),
                    onPressed: () {

                    },
                  ),
                ),
                Align(
                  alignment: const Alignment(0.5, 0),
                  child: IconButton(
                    iconSize: VideoBox.centerIconSize,
                    disabledColor: Colors.white60,
                    icon: const Icon(Icons.skip_next),
                    onPressed: () {},
                  ),
                ),
              ],
            ),
          ),
          ListTile(
            title: const Text('Inverter ordem',
            style: TextStyle(color: Colors.white, fontSize: 18),),
            trailing: const Icon(Icons.swap_vert, color: Colors.white,),
            selectedColor: Colors.white,
            shape: Border.all(
              color: Colors.red.withOpacity(.5),
              width: 1,
            ),
            onTap: () {
              setState(() {
                swap = !swap;
              });
            },
          ),
          // ListView.builder(
          //   shrinkWrap: true,
          //   physics: const NeverScrollableScrollPhysics(),
          //   itemCount: 100,
          //   reverse: swap,
          //   itemBuilder: (context, index) {
          //     return ListTile(
          //       splashColor: Colors.transparent,
          //       selectedTileColor: Colors.transparent,
          //       selected: false,
          //       tileColor: AnimeseColors.background,
          //       title: Text(
          //         'Episódio $index',
          //         style: const TextStyle(fontSize: 20, color: Colors.white),
          //       ),
          //       trailing: const Icon(
          //         Icons.play_arrow,
          //         color: Colors.white,
          //
          //       ),
          //       onTap: () {},
          //     );
          //   },
          // ),
        ],
      ),
    );
  }
}

class VideoBar extends StatelessWidget {
  final VideoController vc;
  final List<double> speeds;

  const VideoBar({
    Key? key,
    required this.vc,
    this.speeds = const [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0],
  }) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Positioned(
      left: 0,
      top: 0,
      right: 0,
      child: AppBar(
        backgroundColor: Colors.transparent,
        title: const Text('test'),
        elevation: 0,
        actions: [
          IconButton(
            icon: const Icon(Icons.more_vert, color: Colors.white,),
            onPressed: () {
              showModalBottomSheet(
                context: context,
                builder: (context) {
                  return Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      ListTile(
                        leading: const Icon(Icons.slow_motion_video),
                        title: const Text('play speed'),
                        onTap: () {
                          showModalBottomSheet<double>(
                            context: context,
                            builder: (context) {
                              return ListView(
                                children: speeds
                                    .map((e) => ListTile(
                                  title: Text(e.toString()),
                                  onTap: () =>
                                      Navigator.of(context).pop(e),
                                ))
                                    .toList(),
                              );
                            },
                          ).then((value) {
                            if (value != null) vc.setPlaybackSpeed(value);
                            Navigator.of(context).pop();
                          });
                        },
                      ),
                    ],
                  );
                },
              );
            },
          ),
        ],
      ),
    );
  }
}
fuedgabriel commented 9 months ago

image