|
|
|
@ -31,9 +31,9 @@ class ClassDetailsVideo extends StatefulWidget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class ClassDetailsVideoState extends State<ClassDetailsVideo> { |
|
|
|
|
late VideoPlayerController videoPlayerController; |
|
|
|
|
late ChewieController chewieAudioController; |
|
|
|
|
late Chewie chewies; |
|
|
|
|
VideoPlayerController? videoPlayerController; |
|
|
|
|
ChewieController? chewieAudioController; |
|
|
|
|
Chewie? chewies; |
|
|
|
|
GlobalKey globalKey = GlobalKey(); |
|
|
|
|
double height = 0; |
|
|
|
|
|
|
|
|
@ -60,14 +60,14 @@ class ClassDetailsVideoState extends State<ClassDetailsVideo> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
initVideo(videoUrl) async { |
|
|
|
|
videoPlayerController.pause(); |
|
|
|
|
videoPlayerController.dispose(); |
|
|
|
|
videoPlayerController?.pause(); |
|
|
|
|
videoPlayerController?.dispose(); |
|
|
|
|
videoPlayerController = VideoPlayerController.networkUrl( |
|
|
|
|
Uri.parse(videoUrl), |
|
|
|
|
)..initialize().then((value) { |
|
|
|
|
chewieAudioController = ChewieController( |
|
|
|
|
videoPlayerController: videoPlayerController, |
|
|
|
|
aspectRatio: videoPlayerController.value.aspectRatio, |
|
|
|
|
videoPlayerController: videoPlayerController!, |
|
|
|
|
aspectRatio: videoPlayerController?.value.aspectRatio, |
|
|
|
|
// aspectRatio: 1.44, |
|
|
|
|
//宽高比 |
|
|
|
|
autoPlay: false, |
|
|
|
@ -87,7 +87,7 @@ class ClassDetailsVideoState extends State<ClassDetailsVideo> {
|
|
|
|
|
// 拖动条样式颜色 |
|
|
|
|
autoInitialize: true, |
|
|
|
|
); |
|
|
|
|
chewieAudioController.addListener(_fullScreenListener); |
|
|
|
|
chewieAudioController?.addListener(_fullScreenListener); |
|
|
|
|
if (mounted) setState(() {}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -101,7 +101,7 @@ class ClassDetailsVideoState extends State<ClassDetailsVideo> {
|
|
|
|
|
), |
|
|
|
|
color: Colors.black, |
|
|
|
|
key: globalKey, |
|
|
|
|
child: (videoPlayerController.value.isInitialized ?? false) |
|
|
|
|
child: (videoPlayerController?.value.isInitialized ?? false) |
|
|
|
|
? videoWidget( |
|
|
|
|
MediaQuery.of(context).size.height, |
|
|
|
|
(MediaQuery.of(context).size.height / 1.44) - 43, |
|
|
|
@ -115,11 +115,11 @@ class ClassDetailsVideoState extends State<ClassDetailsVideo> {
|
|
|
|
|
void dispose() { |
|
|
|
|
super.dispose(); |
|
|
|
|
|
|
|
|
|
chewieAudioController.pause(); |
|
|
|
|
chewieAudioController.dispose(); |
|
|
|
|
chewieAudioController?.pause(); |
|
|
|
|
chewieAudioController?.dispose(); |
|
|
|
|
|
|
|
|
|
videoPlayerController.pause(); |
|
|
|
|
videoPlayerController.dispose(); |
|
|
|
|
videoPlayerController?.pause(); |
|
|
|
|
videoPlayerController?.dispose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget videoWidget(double width, double height, src) { |
|
|
|
@ -137,7 +137,7 @@ class ClassDetailsVideoState extends State<ClassDetailsVideo> {
|
|
|
|
|
height: MediaQuery.of(context).size.width / 1.5, |
|
|
|
|
// margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top), |
|
|
|
|
child: chewies = Chewie( |
|
|
|
|
controller: chewieAudioController, |
|
|
|
|
controller: chewieAudioController!, |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
: Container( |
|
|
|
@ -150,7 +150,7 @@ class ClassDetailsVideoState extends State<ClassDetailsVideo> {
|
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
widget.changeShowImg?.call(false); |
|
|
|
|
chewieAudioController.play(); |
|
|
|
|
chewieAudioController?.play(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
@ -189,7 +189,7 @@ class ClassDetailsVideoState extends State<ClassDetailsVideo> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Future<void> _fullScreenListener() async { |
|
|
|
|
if (!chewieAudioController.isFullScreen) { |
|
|
|
|
if (!(chewieAudioController?.isFullScreen ?? false)) { |
|
|
|
|
Future.delayed(Duration(seconds: 1), () { |
|
|
|
|
widget.exitFull?.call(); |
|
|
|
|
}); |
|
|
|
|