Blame view

lib/pages/video/lookvideo/widgets/video_opera_widget.dart 6.19 KB
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
    const VideoOperaWidget({super.key,
      this.currentTime = '00:00',
      this.totalTime = '00:00',
      this.degree = 0.0,
      this.actionEvent,
95e3448c   liangchengyou   feat:听音选图/选字
22
      this.sliderChangeEvent,
842b7132   liangchengyou   feat:磨耳朵/练习页面调整
23
24
      this.isPlay = true,
      this.title = 'song',
91fe517a   liangchengyou   feat:看视频功能开发
25
    });
119ba920   liangchengyou   feat:视频播放器
26
27
28
29
30
    //当前播放时间
    final String currentTime;
    //总时间
    final String totalTime;
    final double degree;
91fe517a   liangchengyou   feat:看视频功能开发
31
    final bool isPlay;
842b7132   liangchengyou   feat:磨耳朵/练习页面调整
32
    final String title;
91fe517a   liangchengyou   feat:看视频功能开发
33
    final Function(OperationType type)? actionEvent;
95e3448c   liangchengyou   feat:听音选图/选字
34
    final Function(double degree)? sliderChangeEvent;
119ba920   liangchengyou   feat:视频播放器
35
36
37
38
39
40
41
42
  
    @override
    State<StatefulWidget> createState() {
      return _VideoOperaWidgetState();
    }
  }
  
  class _VideoOperaWidgetState extends State<VideoOperaWidget> {
91fe517a   liangchengyou   feat:看视频功能开发
43
44
45
46
47
48
49
50
51
52
53
54
  
    //是否在滑动
    late bool isSlider;
    late double sliderValue;
  
    @override
    void initState() {
      super.initState();
      isSlider = false;
      sliderValue = 0.0;
    }
  
119ba920   liangchengyou   feat:视频播放器
55
56
    @override
    Widget build(BuildContext context) {
91fe517a   liangchengyou   feat:看视频功能开发
57
58
59
60
61
62
63
64
65
      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:视频播放器
66
67
68
69
70
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Row(
                      children: [
91fe517a   liangchengyou   feat:看视频功能开发
71
72
73
74
75
76
77
78
79
                        GestureDetector(
                          onTap: (){
                            widget.actionEvent?.call(OperationType.back);
                          },
                          child: Image.asset(
                              'back_around'.assetPng,
                              height: 40,
                              width: 40
                          ),
119ba920   liangchengyou   feat:视频播放器
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
                        ),
                        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(
842b7132   liangchengyou   feat:磨耳朵/练习页面调整
95
                            widget.title,
119ba920   liangchengyou   feat:视频播放器
96
                            textAlign: TextAlign.center,
3c1d5c64   liangchengyou   feat:练习功能完成
97
                            overflow: TextOverflow.clip,
119ba920   liangchengyou   feat:视频播放器
98
99
100
101
102
103
104
105
                            style: TextStyle(
                              fontSize: 20.sp,
                              color: const Color(0xFF333333),
                            ),
                          ),
                        )
                      ],
                    ),
842b7132   liangchengyou   feat:磨耳朵/练习页面调整
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
                    // 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:视频播放器
131
132
                  ],
                ),
91fe517a   liangchengyou   feat:看视频功能开发
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
              ),
            ),
            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(
bff5c18b   liangchengyou   feat:修复滑动错误问题
149
150
                          min:0,
                          max: 1.0,
91fe517a   liangchengyou   feat:看视频功能开发
151
152
153
154
155
156
157
158
159
160
161
162
163
                          activeColor: Colors.blue,
                          inactiveColor: Colors.white,
                          value: isSlider?sliderValue:widget.degree,
                          onChangeStart: (value) {
                           setState(() {
                             isSlider = true;
                             sliderValue = value;
                           });
                          },
                          onChangeEnd: (value) {
                            setState(() {
                              isSlider = false;
                            });
95e3448c   liangchengyou   feat:听音选图/选字
164
                            widget.sliderChangeEvent?.call(value);
91fe517a   liangchengyou   feat:看视频功能开发
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
                          },
                          onChanged: (value) {
                            setState(() {
                              sliderValue = value;
                            });
                          },
                        ),
                      ),
                      Text(
                        '${widget.currentTime}/${widget.totalTime}',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 12.sp
                        ),
                      )
                    ],
                  ),
                ],
              ),
            )
          ],
119ba920   liangchengyou   feat:视频播放器
186
187
188
189
        ),
      );
    }
  }