From c74a81072e36ddd7e0c149daf5a5299a214f4fcc Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Sun, 26 Nov 2023 20:43:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=B9=E7=AA=97=E6=B5=8B=E8=AF=95=20+=20?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6=E6=8D=95=E8=8E=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 7 ++-- lib/view/video/play_state_dialog.dart | 7 ++++ lib/view/{ => video}/video.dart | 49 ++++++++++++++++++++++++--- 3 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 lib/view/video/play_state_dialog.dart rename lib/view/{ => video}/video.dart (73%) diff --git a/lib/main.dart b/lib/main.dart index 1672111..c38fa4d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:matrix_flutter_app_v2/animate/slide.dart'; import 'package:matrix_flutter_app_v2/view/home.dart'; import 'package:matrix_flutter_app_v2/view/media_query.dart'; -import 'package:matrix_flutter_app_v2/view/video.dart'; +import 'package:matrix_flutter_app_v2/view/video/video.dart'; import 'animate/fade.dart'; @@ -23,13 +23,14 @@ class MyApp extends StatelessWidget { theme: ThemeData( useMaterial3: false, ), - initialRoute: "/", + initialRoute: "/video", routes: { '/': (ctx) => const MyHomePage(title: 'Flutter Demo Home Page'), '/media': (ctx) => const Slide(child: CustomMediaQuery()), // '/video': (ctx)=> const CustomVideoPlayer(url: "http://[2409:8087:1e03:21::2]:6060/cms001/ch00000090990000001022/index.m3u8") //'/video': (ctx)=> const CustomVideoPlayer(url: "http://10.10.10.200:20480/d/sk-pi/sk-16t/Movie/%E5%A5%87%E5%BC%82%E5%8D%9A%E5%A3%AB.MP4?sign=6uVNOeLwBBCB-pVUz1WdLnAS7kWtXq6PQJ5TcCrXKFY=:0") - '/video': (ctx)=> const CustomVideoPlayer(url: "http://[2409:8087:2001:20:2800:0:df6e:eb27]:80/wh7f454c46tw3352677969_1732462333/ott.mobaibox.com/PLTV/3/224/3221228524/index.m3u8") + '/video': (ctx)=> const CustomVideoPlayer(url: "http://10.10.10.200:20480/d/sk-pi/sk-16t/Movie/FV4005%E7%89%B9%E8%BE%91-%E4%B8%80%E7%82%AE%E4%B8%80%E4%B8%AA%E8%BF%98%E6%9C%89%E8%B0%81%EF%BC%9F_%E5%93%94%E5%93%A9%E5%93%94%E5%93%A9%20(%E3%82%9C-%E3%82%9C)%E3%81%A4%E3%83%AD%20%E5%B9%B2%E6%9D%AF~-bilibili.FLV?sign=G79NE1rSQUrofuBiT0PXZpv6lsSvgiij2zfG_SB1eE0=:0") + //'/video': (ctx)=> const CustomVideoPlayer(url: "http://[2409:8087:2001:20:2800:0:df6e:eb27]:80/wh7f454c46tw3352677969_1732462333/ott.mobaibox.com/PLTV/3/224/3221228524/index.m3u8") }, ); } diff --git a/lib/view/video/play_state_dialog.dart b/lib/view/video/play_state_dialog.dart new file mode 100644 index 0000000..56de9c2 --- /dev/null +++ b/lib/view/video/play_state_dialog.dart @@ -0,0 +1,7 @@ +import 'package:flutter/material.dart'; + +class PlayStateDialog extends Dialog { + const PlayStateDialog(this.child, {super.key}); + @override + final Widget child; +} \ No newline at end of file diff --git a/lib/view/video.dart b/lib/view/video/video.dart similarity index 73% rename from lib/view/video.dart rename to lib/view/video/video.dart index ed785cd..aa565b6 100644 --- a/lib/view/video.dart +++ b/lib/view/video/video.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:matrix_flutter_app_v2/animate/fade.dart'; import 'package:video_player/video_player.dart'; import 'package:wakelock/wakelock.dart'; @@ -18,6 +19,7 @@ class CustomVideoPlayer extends StatefulWidget { class _CustomVideoPlayerState extends State { VideoPlayerController? _controller; Timer? _timer; + List showWidget = []; _CustomVideoPlayerState(); @@ -31,7 +33,6 @@ class _CustomVideoPlayerState extends State { [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]); Wakelock.enable(); initVideoPlayer(); - // initFijkPlayer(); } void initVideoPlayer() { @@ -42,6 +43,45 @@ class _CustomVideoPlayerState extends State { _controller!.play(); }); }); + _controller!.addListener(() {}); + setState(() { + showWidget.add( + GestureDetector( + onTap: (){ + VideoPlayerValue value = _controller!.value; + if(value.isPlaying) { + if(value.isCompleted){ + _controller!.seekTo(Duration.zero); + } else { + _controller!.pause(); + } + } else { + _controller!.play(); + } + }, + child: VideoPlayer(_controller!), + ), + ); + }); + + showWidget.add( + const Fade( + child: Opacity( + opacity: 0.8, + child: Dialog.fullscreen( + child: Center( + child: Text("测试"), + ), + ), + ), + ), + ); + + Timer(const Duration(seconds: 1), () { + setState(() { + showWidget.removeLast(); + }); + }); } void onKey(RawKeyEvent event) { @@ -71,9 +111,6 @@ class _CustomVideoPlayerState extends State { @override Widget build(BuildContext context) { return Scaffold( - // appBar: AppBar( - // toolbarHeight: 35, - // ), backgroundColor: Colors.black, body: PopScope( onPopInvoked: (val) { @@ -90,7 +127,9 @@ class _CustomVideoPlayerState extends State { onKey: onKey, autofocus: true, focusNode: FocusNode(), - child: VideoPlayer(_controller!), + child: Stack( + children: showWidget, + ), ), ) : Container(),