작성
·
446
·
수정됨
0
아래와 같이 동영상 보고 따라 하였는데 원인이 무엇일까요?
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:video_player/video_player.dart';
class CustomVideoPlayer extends StatefulWidget {
final XFile video;
const CustomVideoPlayer({required this.video, Key? key}) : super(key: key);
@override
State<CustomVideoPlayer> createState() => _CustomVideoPlayerState();
}
class _CustomVideoPlayerState extends State<CustomVideoPlayer> {
VideoPlayerController? videoPlayerController;
@override
void initState() {
// TODO: implement initState
super.initState();
initialController();
}
initialController() async {
videoPlayerController = VideoPlayerController.file(File(widget.video.path));
await videoPlayerController!.initialize();
setState(() {});
}
@override
Widget build(BuildContext context) {
if (videoPlayerController == null) {
return CircularProgressIndicator();
}
return AspectRatio(
aspectRatio: videoPlayerController!.value.aspectRatio,
child: VideoPlayer(videoPlayerController!));
}
}