弹窗测试 + 点击事件捕获
This commit is contained in:
parent
931df661df
commit
c74a81072e
@ -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")
|
||||
},
|
||||
);
|
||||
}
|
||||
|
7
lib/view/video/play_state_dialog.dart
Normal file
7
lib/view/video/play_state_dialog.dart
Normal file
@ -0,0 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PlayStateDialog extends Dialog {
|
||||
const PlayStateDialog(this.child, {super.key});
|
||||
@override
|
||||
final Widget child;
|
||||
}
|
@ -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<CustomVideoPlayer> {
|
||||
VideoPlayerController? _controller;
|
||||
Timer? _timer;
|
||||
List<Widget> showWidget = [];
|
||||
|
||||
_CustomVideoPlayerState();
|
||||
|
||||
@ -31,7 +33,6 @@ class _CustomVideoPlayerState extends State<CustomVideoPlayer> {
|
||||
[DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
|
||||
Wakelock.enable();
|
||||
initVideoPlayer();
|
||||
// initFijkPlayer();
|
||||
}
|
||||
|
||||
void initVideoPlayer() {
|
||||
@ -42,6 +43,45 @@ class _CustomVideoPlayerState extends State<CustomVideoPlayer> {
|
||||
_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<CustomVideoPlayer> {
|
||||
@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<CustomVideoPlayer> {
|
||||
onKey: onKey,
|
||||
autofocus: true,
|
||||
focusNode: FocusNode(),
|
||||
child: VideoPlayer(_controller!),
|
||||
child: Stack(
|
||||
children: showWidget,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
Loading…
Reference in New Issue
Block a user