119ba920
liangchengyou
feat:视频播放器
|
1
2
3
4
|
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/common/extension/string_extension.dart';
|
91fe517a
liangchengyou
feat:看视频功能开发
|
5
6
7
8
9
10
11
12
13
14
15
|
enum OperationType {
//返回
back,
//字幕
subtitlesState,
//静音
audioState,
//暂停/播放
playState,
}
|
119ba920
liangchengyou
feat:视频播放器
|
16
|
class VideoOperaWidget extends StatefulWidget {
|
91fe517a
liangchengyou
feat:看视频功能开发
|
17
18
19
20
21
22
23
|
const VideoOperaWidget({super.key,
this.currentTime = '00:00',
this.totalTime = '00:00',
this.degree = 0.0,
this.actionEvent,
this.isPlay = true
});
|
119ba920
liangchengyou
feat:视频播放器
|
24
25
26
27
28
|
//当前播放时间
final String currentTime;
//总时间
final String totalTime;
final double degree;
|
91fe517a
liangchengyou
feat:看视频功能开发
|
29
30
|
final bool isPlay;
final Function(OperationType type)? actionEvent;
|
119ba920
liangchengyou
feat:视频播放器
|
31
32
33
34
35
36
37
38
|
@override
State<StatefulWidget> createState() {
return _VideoOperaWidgetState();
}
}
class _VideoOperaWidgetState extends State<VideoOperaWidget> {
|
91fe517a
liangchengyou
feat:看视频功能开发
|
39
40
41
42
43
44
45
46
47
48
49
50
|
//是否在滑动
late bool isSlider;
late double sliderValue;
@override
void initState() {
super.initState();
isSlider = false;
sliderValue = 0.0;
}
|
119ba920
liangchengyou
feat:视频播放器
|
51
52
|
@override
Widget build(BuildContext context) {
|
91fe517a
liangchengyou
feat:看视频功能开发
|
53
54
55
56
57
58
59
60
61
|
return SizedBox(
width: double.infinity,
height: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SafeArea(
child: Padding(
padding: EdgeInsets.only(top: 11.h),
|
119ba920
liangchengyou
feat:视频播放器
|
62
63
64
65
66
|
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
|
91fe517a
liangchengyou
feat:看视频功能开发
|
67
68
69
70
71
72
73
74
75
|
GestureDetector(
onTap: (){
widget.actionEvent?.call(OperationType.back);
},
child: Image.asset(
'back_around'.assetPng,
height: 40,
width: 40
),
|
119ba920
liangchengyou
feat:视频播放器
|
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
),
18.horizontalSpace,
Container(
height: 40.h,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6.r),
border: Border.all(
width: 1.5,
color: const Color(0xFF140C10)
)
),
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: Text(
'song',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.sp,
color: const Color(0xFF333333),
),
),
)
],
),
|
91fe517a
liangchengyou
feat:看视频功能开发
|
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
GestureDetector(
onTap: () {
widget.actionEvent?.call(OperationType.subtitlesState);
},
child: Container(
height: 40.h,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6.r),
border: Border.all(
width: 1.5,
color: const Color(0xFF140C10)
)
),
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: Text(
'中/英',
style: TextStyle(
fontSize: 20.sp,
color: const Color(0xFF333333),
),
|
119ba920
liangchengyou
feat:视频播放器
|
123
124
125
126
127
|
),
),
)
],
),
|
91fe517a
liangchengyou
feat:看视频功能开发
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
),
),
Container(
color: Colors.white10,
height: 47.h+ScreenUtil().bottomBarHeight,
padding: EdgeInsets.symmetric(horizontal: 11.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
children: [
IconButton(onPressed: (){
widget.actionEvent?.call(OperationType.playState);
}, icon: widget.isPlay?const Icon(Icons.pause,color: Colors.white,):const Icon(Icons.play_arrow,color: Colors.white),),
Expanded(
child: Slider(
activeColor: Colors.blue,
inactiveColor: Colors.white,
value: isSlider?sliderValue:widget.degree,
onChangeStart: (value) {
setState(() {
isSlider = true;
sliderValue = value;
});
},
onChangeEnd: (value) {
setState(() {
isSlider = false;
});
},
onChanged: (value) {
setState(() {
sliderValue = value;
});
},
),
),
Text(
'${widget.currentTime}/${widget.totalTime}',
style: TextStyle(
color: Colors.white,
fontSize: 12.sp
),
)
],
),
],
),
)
],
|
119ba920
liangchengyou
feat:视频播放器
|
178
179
180
181
|
),
);
}
}
|