appinio_video_player 1.3.0 appinio_video_player: ^1.3.0 copied to clipboard
A custom video player that builds on top of the official video_player package by flutter and adds many functionalities.
import 'package:appinio_video_player/appinio_video_player.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const CupertinoApp(
debugShowCheckedModeBanner: false,
theme: CupertinoThemeData(
brightness: Brightness.light,
),
title: 'Appinio Video Player Demo',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
late CachedVideoPlayerController _videoPlayerController,
_videoPlayerController2,
_videoPlayerController3;
late CustomVideoPlayerController _customVideoPlayerController;
late CustomVideoPlayerWebController _customVideoPlayerWebController;
final CustomVideoPlayerSettings _customVideoPlayerSettings =
const CustomVideoPlayerSettings(showSeekButtons: true);
final CustomVideoPlayerWebSettings _customVideoPlayerWebSettings =
CustomVideoPlayerWebSettings(
src: longVideo,
);
@override
void initState() {
super.initState();
_videoPlayerController = CachedVideoPlayerController.network(
longVideo,
)..initialize().then((value) => setState(() {}));
_videoPlayerController2 = CachedVideoPlayerController.network(video240);
_videoPlayerController3 = CachedVideoPlayerController.network(video480);
_customVideoPlayerController = CustomVideoPlayerController(
context: context,
videoPlayerController: _videoPlayerController,
customVideoPlayerSettings: _customVideoPlayerSettings,
additionalVideoSources: {
"240p": _videoPlayerController2,
"480p": _videoPlayerController3,
"720p": _videoPlayerController,
},
);
_customVideoPlayerWebController = CustomVideoPlayerWebController(
webVideoPlayerSettings: _customVideoPlayerWebSettings,
);
}
@override
void dispose() {
_customVideoPlayerController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: const CupertinoNavigationBar(
middle: Text("Appinio Video Player"),
),
child: SafeArea(
child: ListView(
physics: const NeverScrollableScrollPhysics(),
children: [
kIsWeb
? Expanded(
child: CustomVideoPlayerWeb(
customVideoPlayerWebController:
_customVideoPlayerWebController,
),
)
: CustomVideoPlayer(
customVideoPlayerController: _customVideoPlayerController,
),
CupertinoButton(
child: const Text("Play Fullscreen"),
onPressed: () {
if (kIsWeb) {
_customVideoPlayerWebController.setFullscreen(true);
_customVideoPlayerWebController.play();
} else {
_customVideoPlayerController.setFullscreen(true);
_customVideoPlayerController.videoPlayerController.play();
}
},
),
],
),
),
);
}
}
String videoUrlLandscape =
"https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4";
String videoUrlPortrait =
'https://assets.mixkit.co/videos/preview/mixkit-a-girl-blowing-a-bubble-gum-at-an-amusement-park-1226-large.mp4';
String longVideo =
"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4";
String video720 =
"https://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_10mb.mp4";
String video480 =
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerBlazes.mp4";
String video240 =
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4";