chewie
chewie copied to clipboard
List of videos
Hi,
I tried following your sample code and creating a listview of videos. I can see the layout of the card, the title, description and the bottom bar where the play and duration sliders are. However, the videos are not displaying.
Here's my code if anyone can help, that would be great
import 'package:chewie/chewie.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
void main() {
runApp(
new ChewieDemo(
items: [
new VideoItem(
title: 'Fluttering Butterfly',
description: 'A lovely butterfly flapping it\'s wings',
controller: new VideoPlayerController.network(
'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4',
),
),
new VideoItem(
title: 'Beeeeeeeees!',
description: 'Silly little bee',
controller: new VideoPlayerController.network(
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4',
),
)
],
),
);
}
class VideoItem {
final String title;
final String description;
final VideoPlayerController controller;
VideoItem({this.title, this.description, this.controller});
}
class ChewieDemo extends StatefulWidget {
final String title;
final List<VideoItem> items;
ChewieDemo({this.title = 'Chewie Demo', this.items});
@override
State<StatefulWidget> createState() {
return new _ChewieDemoState();
}
}
class _ChewieDemoState extends State<ChewieDemo> {
TargetPlatform _platform;
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: widget.title,
theme: new ThemeData.light().copyWith(
platform: _platform ?? Theme.of(context).platform,
),
home: new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new ListView(
children: widget.items.map((item) {
return new Container(
margin: new EdgeInsets.only(bottom: 20.0),
child: new Card(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
item.title,
style: Theme.of(context).textTheme.title,
),
new Text(
item.description,
style: Theme.of(context).textTheme.subhead,
),
new Chewie(
controller: ChewieController(videoPlayerController: item.controller),
),
],
),
),
);
}).toList(),
),
),
);
}
}
I found it. But I believe there's a bug. If you set autoplay to false it doesn't load the video. Even if you press on play it won't work.
autoPlay: true,
aspectRatio: 3 / 2,
looping: false
Closing. Duplicate issue: https://github.com/brianegan/chewie/issues/229