Blame view

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