cached_video_player 1.0.2 cached_video_player: ^1.0.2 copied to clipboard
A new flutter plugin that is virtually a clone of official video_player plugin except that it supports caching( Android for now)
import 'package:cached_video_player/cached_video_player.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
CachedVideoPlayerController controller;
@override
void initState() {
controller = CachedVideoPlayerController.network(
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4");
controller.initialize().then((_) {
setState(() {});
controller.play();
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: controller.value != null && controller.value.initialized
? AspectRatio(
child: CachedVideoPlayer(controller),
aspectRatio: controller.value.aspectRatio,
)
: Center(
child: CircularProgressIndicator(),
)),
);
}
}