I'm using video_player package to play a video in my app. I set the setLooping
to true so the VideoPlayer
will play all the time.
But I get the following error in the terminal all the time after using the video_player plugin:
.
My computer also heats up when I'm using the video player.
This is the code:
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:spiran_app/models/constants.dart';
import 'package:spiran_app/models/products_manager.dart';
import 'package:video_player/video_player.dart';
import 'package:spiran_app/screens/bottom_nav_bar_screen.dart';
import 'package:spiran_app/screens/shop_screen.dart';
import 'package:spiran_app/widgets/main_screen_page_widget.dart';
import 'package:spiran_app/widgets/main_screen_products_grid_widget.dart';
class MainScreen extends StatefulWidget {
MainScreen({@required this.shopButtonPressed});
final VoidCallback shopButtonPressed;
static const String routeName = "/main_screen";
@override
_MainScreenState createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
final PageController pageController = PageController(initialPage: 0);
final VideoPlayerController _videoPlayerController =
VideoPlayerController.asset(
"lib/videos/spiran_video.MOV",
);
Future<void> _videoPlayerControllerInitializer;
@override
void initState() {
_videoPlayerControllerInitializer = _videoPlayerController.initialize();
_videoPlayerController.setLooping(true);
super.initState();
}
@override
void dispose() {
this._videoPlayerController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final ProductsManager productsManager =
Provider.of<ProductsManager>(context);
final ThemeData theme = Theme.of(context);
final MediaQueryData mediaQueryData = MediaQuery.of(context);
return Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
AspectRatio(
aspectRatio: _videoPlayerController.value.aspectRatio,
child: FutureBuilder(
future: this._videoPlayerControllerInitializer,
builder: (ctx, videoPlayerControllerSnapshot) {
if (videoPlayerControllerSnapshot.connectionState ==
ConnectionState.done) {
this._videoPlayerController.play();
return Stack(
children: [
VideoPlayer(
this._videoPlayerController,
),
Container(
alignment: Alignment.center,
padding: Constants.constContainerPadding,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.transparent, Colors.black],
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
),
child: Text(
"Highest Quality Saffron",
style: theme.textTheme.headline4.apply(
color: Colors.white,
shadows: [
Shadow(color: Colors.black, blurRadius: 20),
],
),
),
)
],
);
}
return Center(
child: CircularProgressIndicator(
backgroundColor: theme.primaryColor,
),
);
},
),
),
Container(
child: ProductsManager().products[0].images[0],
),
],
),
),
);
}
}
What is the problem here?
Thanks
question from:
https://stackoverflow.com/questions/65843493/video-player-package-error-while-playing-video 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…