GithubHelp home page GithubHelp logo

januwa / flutter_video_box Goto Github PK

View Code? Open in Web Editor NEW
22.0 1.0 8.0 574 KB

flutter_video_box

License: MIT License

Objective-C 0.03% Dart 60.78% Shell 0.46% Kotlin 0.11% Swift 1.11% HTML 1.58% CMake 16.29% C++ 18.39% C 1.24%

flutter_video_box's Introduction

video_box

Play video in Flutter

note:

  • Only tested on android

android: <project root>/android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

ios: <project root>/ios/Runner/Info.plist:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

Usage

import 'package:flutter/material.dart';
import 'package:video_box/video.controller.dart';
import 'package:video_box/video_box.dart';
import 'package:video_player/video_player.dart';

class ListVideo extends StatefulWidget {
  @override
  _ListVideoState createState() => _ListVideoState();
}

class _ListVideoState extends State<ListVideo> {
  List<VideoController> vcs = [];

  @override
  void initState() {
    super.initState();
    for (var i = 0; i < 4; i++) {
      vcs.add(VideoController(source: VideoPlayerController.network(src1))
        ..initialize());
    }
  }

  @override
  void dispose() {
    for (var vc in vcs) {
      vc.dispose();
    }
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('list video'),
      ),
      body: ListView(
        children: <Widget>[
          for (var vc in vcs)
            Padding(
              padding: const EdgeInsets.only(top: 12.0),
              child: AspectRatio(
                aspectRatio: 16 / 9,
                child: VideoBox(controller: vc),
              ),
            ),
        ],
      ),
    );
  }
}

Catch the error during initialize

  vc = VideoController(
    source: VideoPlayerController.network('https://examole.com/a.mp4'),
  )
    ..addInitializeErrorListenner((e) {
      print('[video box init] error: ' + e.message);
    })
    ..initialize().then((e) {
      if (e != null) {
        print('[video box init] error: ' + e.message);
      } else {
        print('[video box init] success');
      }
    });

For details, see /example or source code.

show:

flutter_video_box's People

Contributors

januwa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flutter_video_box's Issues

missing options in the new release

Hi,
I upgraded to the new version and am not finding the equivalent of the cover, bottomPadding, customFullScreen in VideoController class, could it help me? thanks

  vcs = new VideoController(
        bottomPadding: EdgeInsets.all(25),
        customFullScreen: const MyFullScreen(),
        controllerLiveDuration: Duration(seconds: 10),
        animetedIconDuration: Duration(milliseconds: 200),
        cover: Center(

The slide control is very close to the edge of the screen

Hi

I have an S-10 galaxy and the slide control is very close to the edge of the screen and I have a lot of difficulty using this control with my finger.
I would suggest that this slide be placed higher, so that control would fail.
I tested it with an Iphone 7 plus and the case and had the same problem.
v2

Exception error when dispose controller

Hi.
when I change the page I had this error.

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown while finalizing the widget tree:
_VideoBoxState#8907b(tickers: tracking 3 tickers) was disposed with an active Ticker.

_VideoBoxState created a Ticker via its TickerProviderStateMixin, but at the time dispose() was called on the mixin, that Ticker was still active. All Tickers must be disposed before calling super.dispose().

Tickers used by AnimationControllers should be disposed by calling dispose() on the AnimationController itself. Otherwise, the ticker will leak.

The offending ticker was: _WidgetTicker(created by _VideoBoxState#8907b(lifecycle state: created, tickers: tracking 2 tickers))
The stack trace when the _WidgetTicker was actually created was:
#0      new Ticker.<anonymous closure> (package:flutter/src/scheduler/ticker.dart:66:40)

I put in my code but doesn´t work:

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

Error playing http links with android 10( Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException)

The error only occurs when I try to play a video with an http link.
but this error only happened on the phone: xiaomi mi lite 8 with android 10
link: http://svr1---s551-xjgk1ahg-cdn.gvideo.g-storage.network/animes/b-4/animes/dragon-ball-z/dublado/hd/290.mp4?rm=FygGMOYAxseNJZBhiUN7_w&rf=1588004824
Ithink this erro is caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
I can only play https links and I cannot play http links because of the certificate.

Erro -------------------------------------------------------------------------------------------------

E/flutter (19527): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to http://svr1---s551-xjgk1ahg-cdn.gvideo.g-storage.network/animes/b-4/animes/dragon-ball-z/dublado/hd/290.mp4?rm=FygGMOYAxseNJZBhiUN7_w&rf=1588004824, null)
E/flutter (19527): #0 _VideoController.initialize (package:video_box/video.controller.dart:595:5)
E/flutter (19527):
E/flutter (19527): #1 _$VideoController.initialize. (package:video_box/video.controller.g.dart:304:52)
E/flutter (19527): #2 _rootRun (dart:async/zone.dart:1126:13)
E/flutter (19527): #3 _ZoneDelegate.run (dart:async/zone.dart:713:19)
E/flutter (19527): #4 AsyncAction._run (package:mobx/src/api/async/async_action.dart:44:29)
E/flutter (19527): #5 _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (19527): #6 AsyncAction.run (package:mobx/src/api/async/async_action.dart:29:26)
E/flutter (19527): #7 _$VideoController.initialize (package:video_box/video.controller.g.dart:304:36)
E/flutter (19527): #8 _PlayerVideoState.initState (package:animese/screens/Player/Player.dart:65:9)
E/flutter (19527): #9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
E/flutter (19527): #10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter (19527): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (19527): #12 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (19527): #13 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter (19527): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (19527): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (19527): #16 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (19527): #17 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (19527): #18 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter (19527): #19 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter (19527): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (19527): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (19527): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter (19527): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (19527): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (19527): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter (19527): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (19527): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (19527): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (19527): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (19527): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4206:5)
E/flutter (19527): #31 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4381:11)
E/flutter (19527): #32 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter (19527): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (19527): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (19527): #35 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter (19527): #36 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (19527): #37 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (19527): #38 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)
E/flutter (19527): #39 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (19527): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (19527): #41 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
E/flutter (19527): #42 Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
E/flutter (19527): #43 Comp


Links with similar errors:
google/ExoPlayer#4204
google/ExoPlayer#4599
https://www.gitmemory.com/issue/flutter/flutter/36849/515026135
Oficcial:
flutter/flutter#56020
flutter/flutter#26851

methods

have you an idea about use methods as oncompleted((controller){
//update list of completed lessions
})

?

is there any way to cache list of network video with video box?

Here is my code

class _PageOneState extends State<PageOne> {
  // List<Video> video = List();
  bool fetchVideoFromOnline = true;
  List<VideoController> vc = [];
  List<String> vcs = [];
  List<Video> videoList = List<Video>();
  File file;


  @override
  void initState() {
    super.initState();
    // getCategory();
    getVideo().then((value) async {
      videoList = value;
      var url = "http://192.168.0.114:3001/public/";
      for (int i = 0; i < videoList.length; i++) {
        var baseUrl = url + videoList[i].videourl;
        print("heeeeeeeeeeeeeeeeeeeeeeeeeeeeelll" + baseUrl);
        // FileInfo fileInfo = await DefaultCacheManager()
        //     .getFileFromCache(baseUrl); //url of video

        // if (fileInfo.file == null) {
        //   print('cache ln: caching now ');

        //   setState(() {
        //     fetchVideoFromOnline = true;
        //   });

        //   file = await DefaultCacheManager().getSingleFile(
        //       baseUrl); //here we provide the url of video to cache.
        // } else {
        //   print('cache ln: ${fileInfo.validTill}');
        //   setState(() {
        //     fetchVideoFromOnline = false;
        //     file = fileInfo.file;
        //   });
        // }
        vcs.add(baseUrl);
      }

      for (var i = 0; i < vcs.length; i++) {
        vc.add(VideoController(source: VideoPlayerController.network(vcs[i]))
          ..initialize());
      }
      print("category length" + videoList.length.toString());
    });
  }

  Future<List<Video>> getVideo() async {
    List<Video> videos = List<Video>();
    await Future.delayed(Duration(seconds: 2));
    var url = Api.GET_VIDEOS;
    var res = await http.get(url);

    if (res.statusCode == 200) {
      var data = jsonDecode(res.body);
      // SQLiteDbProvider.db.deleCategory();
      for (int i = 0; i < data.length; i++) {
        Video video = Video(
            data[i]['Videoid'],
            data[i]['Videourl'],
            data[i]['Caption'],
            data[i]['Categoryid'],
            data[i]['Userpostid'],
            data[i]['Userid'],
            data[i]['Viewcount'],
            data[i]['Likecount'],
            data[i]['Createdate']);
        videos.add(video);
        // SQLiteDbProvider.db.insertCategory(category);
      }
      print(data);
    }
    return videos;
  }

  @override
  void dispose() {
    for (var v in vc) {
      v.dispose();
    }
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: FutureBuilder(
            future: getVideo(),
            builder: (ctx, snapshot) {
              if (snapshot.hasError) {
                return Container(
                  child: Text('Error ${snapshot.error}'),
                );
              } else if (snapshot.hasData) {
                List<Video> videos = snapshot.data;
                return ListView.builder(
                  itemCount: videos.length,
                  itemBuilder: (BuildContext ctx, int index) {
                    // for (var v in vc)
                    return Padding(
                      padding: const EdgeInsets.only(top: 12.0),
                      child: Column(
                        children: <Widget>[
                          AspectRatio(
                            aspectRatio: 16 / 9,
                            child: VideoBox(
                              controller: vc[index],
                              // controller: fetchVideoFromOnline
                              //     ? (vc[index]) //url of video
                              //     : VideoPlayerController.file(file), //
                              children: <Widget>[
                                Stack(
                                    alignment: Alignment.center,
                                    children: <Widget>[
                                      Positioned(
                                        left: 20.0,
                                        top: 0.0,
                                        child: Text(
                                          videos[index].caption,
                                          style: TextStyle(
                                              color: Colors.white,
                                              fontSize: 20.0),
                                        ),
                                      ),
                                    ])
                              ],
                            ),
                          ),
                          Container(
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: <Widget>[
                                Padding(
                                  padding: const EdgeInsets.all(5.0),
                                  child: Row(
                                    children: <Widget>[
                                      CircleAvatar(
                                        backgroundImage: NetworkImage(
                                            "https://images.pexels.com/photos/230860/pexels-photo-230860.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"),
                                      ),
                                      Padding(
                                        padding: const EdgeInsets.fromLTRB(
                                            8.0, 0.0, 0.0, 0.0),
                                        child: Text("fsfzsfd",
                                            style: TextStyle(
                                              color: Colors.grey,
                                            )),
                                      )
                                    ],
                                  ),
                                ),
                                Padding(
                                  padding: const EdgeInsets.fromLTRB(
                                      0.0, 0.0, 10.0, 0.0),
                                  child: Row(
                                    children: <Widget>[
                                      Padding(
                                        padding: const EdgeInsets.all(8.0),
                                        child: Icon(Icons.thumb_up),
                                      ),
                                      Padding(
                                        padding: const EdgeInsets.all(8.0),
                                        child: GestureDetector(
                                          onTap: () {
                                            Navigator.push(
                                              context,
                                              MaterialPageRoute(
                                                  builder: (context) =>
                                                      CommentPage()),
                                            );
                                          },
                                          child: Icon(
                                            Icons.message,
                                            size: 20.0,
                                          ),
                                        ),
                                      ),
                                      // Icon(Icons.more_horiz, size: 30,)
                                      IconButton(
                                        icon: Icon(
                                          Icons.more_horiz,
                                        ),
                                        onPressed: () {},
                                      )
                                    ],
                                  ),
                                )
                              ],
                            ),
                          )
                        ],
                      ),
                    );
                  },
                );
              }

I want to keep auto init video in list!

Hey master, i want to keep auto init video in list. instead i want to display image and click image to init video in list!. i need a idel can you help me

删除平台差异

在这个#2问题后,我在v0.6.0加入了手势控制音量和亮度功能,但是此功能引进了两个外部依赖包,并造成了平台差异。
v0.9.1版本将会删除这两个功能,如需使用这两个功能,请参考以前的代码,在外部实现。

Erro Theme

Performing hot reload...
Syncing files to device Custom Phone 1...

Compiler message:
/C:/SRC/flutter/.pub-cache/hosted/pub.dartlang.org/video_box-0.10.0/lib/widgets/buffer_slider.dart:101:27: Error: The getter 'bodyText1' isn't defined for the class 'TextTheme'.

  • 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/C:/SRC/flutter/packages/flutter/lib/src/material/text_theme.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'bodyText1'.
    theme.textTheme.bodyText1.copyWith(
    ^^^^^^^^^

Missing imports of 'package:flutter/rendering.dart'

I got the following error when I updated my flutter to the latest master


Compiler message:
/D:/apps/flutter/.pub-cache/hosted/pub.flutter-io.cn/video_box-0.12.0/lib/widgets/buffer_slider.dart:165:31: Error: The getter 'Overflow' isn't defined for the class 'BufferSlider'.
 - 'BufferSlider' is from 'package:video_box/widgets/buffer_slider.dart' ('/D:/apps/flutter/.pub-cache/hosted/pub.flutter-io.cn/video_box-0.12.0/lib/widgets/buffer_slider.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Overflow'.
                    overflow: Overflow.visible,
                              ^^^^^^^^

The output of flutter doctor is the following.

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 1.19.0-2.0.pre.213, on Microsoft Windows [Version 10.0.19041.264], locale en-US)
 
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.5.4)   
[√] Android Studio (version 3.6)
[√] VS Code, 64-bit edition (version 1.45.1)
[√] Connected device (4 available)

• No issues found!

If I manual add this line (import 'package:flutter/rendering.dart';), then this error disappeared.

In fullscreen mode on iOS the video is upside down

Giving you feedback.
I know you haven't tested it on iOS.

I tested it on the Iphone 7 plus and the only problem I found is that in fullscreen mode the video is upside down. I tried to turn the screen to the right and left and the video (full screen) is always upside down.
On android it works well.

To fix this issue you I think you must to detect the OS and change (event.x > 1) and (event.x < -1), to iOS is inverse. I tested/inverse and work well.

FOR iOS

  StreamSubscription<dynamic> _streamSubscriptions$;
  void _streamSubscriptionsCallback(AccelerometerEvent event) {
    if (!isFullScreen) return;
    bool isHorizontal = event.x.abs() > event.y.abs(); // 横屏模式
    if (!isHorizontal) return;
    if (event.x > 1) {
      SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeRight]);
    } else if (event.x < -1) {
      SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);
    }
  }

FOR ANDROID

      StreamSubscription<dynamic> _streamSubscriptions$;
        void _streamSubscriptionsCallback(AccelerometerEvent event) {
            if (!isFullScreen) return;
           bool isHorizontal = event.x.abs() > event.y.abs(); // 横屏模式
           if (!isHorizontal) return;
              if (event.x > 1) {
                 SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);
             } else if (event.x < -1) {
                SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeRight]);
                 }
             }

Compiler message:

i got this issue
Compiler message:
/C:/Users/Dell/flutter/.pub-cache/hosted/pub.dartlang.org/video_box-0.7.2/lib/video.controller.dart:457:11: Error: Superclass has no method named 'dispose'.
super.dispose();
^^^^^^^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.

FAILURE: Build failed with an exception.

  • Where:
    Script 'C:\Users\Dell\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 780

  • What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'C:\Users\Dell\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 20s
Finished with error: Gradle task assembleDebug failed with exit code 1

and everything worked fine after i deleted the following line from video.controller.dart

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)

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();
                          });
                        },
                      ),
                    ],
                  );
                },
              );
            },
          ),
        ],
      ),
    );
  }
}

How to add a title to the video and update the title?

AspectRatio(
aspectRatio: 16 / 9,
child: VideoBox(
controller: vc,
children: [
Align(
alignment: Alignment((MediaQuery.of(context).size.height * 0.0004)-1, (MediaQuery.of(context).size.width * 0.0020)-1),
child: Text(
episodeActualy,
style: TextStyle(
fontSize: 16,
color: Colors.white
),
)
),
],
),
),

SetState does not work on VideoBox.
setState(() {
episodeActualy = ' class 01';
});

Compilation error

C:\SRC\flutter\bin\flutter.bat --no-color build apk
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...
Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

Note: C:\SRC\flutter.pub-cache\hosted\pub.dartlang.org\video_player-0.10.8+1\android\src\main\java\io\flutter\plugins\videoplayer\VideoPlayerPlugin.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

Calling mockable JAR artifact transform to create file: C:\Users\House.gradle\caches\transforms-2\files-2.1\80784612055a36fb80116b31921330f1\android.jar with input C:\Users\House\AppData\Local\Android\sdk\platforms\android-28\android.jar

Removed unused resources: Binary resource data reduced from 44KB to 35KB: Removed 20%
Running Gradle task 'assembleRelease'... 176.8s (!)
√ Built build\app\outputs\apk\release\app-release.apk (49.0MB).
Process finished with exit code 0

Exception has occurred. MissingPluginException (MissingPluginException(No implementation found for method controlVolume on channel volume))

While testing on ios, i got the following exception in initializer.

Exception has occurred.
MissingPluginException (MissingPluginException(No implementation found for method controlVolume on channel volume))
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.13.1-pre.15, on Mac OS X 10.15.1 19B88, locale en-GB)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] Connected device (4 available)

• No issues found!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.