fluttercommunity / fluttercommunity/chewie

Chewie takes till three seconds to load and render a network video

Open
#486 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Dart
Stars
2.1k
Forks
1.1k
Avg merge
6d 8h
Merged PRs (30d)
6

Description

Hello,

We are using this package to handle videos on our app.

To do this we created a simple `VideoItem` to get a `VideoPlayerController` and rendering it:
```dart
class VideoItem extends StatefulWidget {
const VideoItem({
Key? key,
required this.videoPlayerController,
this.autoplay = false,
this.looping = false,
}) : super(key: key);

final VideoPlayerController videoPlayerController;
final bool looping;
final bool autoplay;

@override
_VideoItemState createState() => _VideoItemState();
}

class _VideoItemState extends State {
late ChewieController _chewieController;

@override
void initState() {
super.initState();
_chewieController = ChewieController(
videoPlayerController: widget.videoPlayerController,
aspectRatio: 5 / 8,
autoInitialize: true,
autoPlay: widget.autoplay,
looping: widget.looping,
showControls: false,
errorBuilder: (context, errorMessage) {
return Center(
child: Text(
errorMessage,
style: const TextStyle(color: Colors.white),
),
);
},
);
}

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

@override
Widget build(BuildContext context) {
return Chewie(controller: _chewieController);
}
}
```

We are using this to render a video from an _url_:
```dart
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: IntroductionScreen(
pages: [
PageViewModel(
title: "",
image: VideoItem(
videoPlayerController: VideoPlayerController.network(dataSource), // <-- Video here
autoplay: true,
),
body: "",
decoration: const PageDecoration(fullScreen: true),
),
],
done: const Text("Done", style: TextStyle(fontWeight: FontWeight.w600)),
onDone: onDone,
showNextButton: false,
),
);
}
```

The problem here is, **chewie** takes so much time to load and play the video (time between we see de `Done` button and the video is rendered and played):
![Record_select-area_20210602155927](https://user-images.githubusercontent.com/5034215/120485846-28762a00-c3bd-11eb-8130-41ee91c80c62.gif)

It seems to be related to this [question](https://stackoverflow.com/questions/61622211/s3-video-and-chewei-loading-videos-too-slow#comment119848069_61622211).

Why does this happen?

Thanks

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.