@@ -12,16 +12,21 @@ class VideoPageBuilder extends StatefulWidget {
12
12
Key ? key,
13
13
required this .asset,
14
14
required this .state,
15
+ this .hasOnlyOneVideoAndMoment = false ,
15
16
}) : super (key: key);
16
17
17
18
/// Asset currently displayed.
18
19
/// 展示的资源
19
20
final AssetEntity asset;
20
21
21
22
/// [State] for asset picker viewer.
22
- /// 资源查看器的状态[State]
23
+ /// 资源查看器的状态 [State]
23
24
final AssetPickerViewerState <AssetEntity , AssetPathEntity > state;
24
25
26
+ /// Only previewing one video and with the [SpecialPickerType.wechatMoment] .
27
+ /// 是否处于 [SpecialPickerType.wechatMoment] 且只有一个视频
28
+ final bool hasOnlyOneVideoAndMoment;
29
+
25
30
@override
26
31
_VideoPageBuilderState createState () => _VideoPageBuilderState ();
27
32
}
@@ -81,7 +86,12 @@ class _VideoPageBuilderState extends State<VideoPageBuilder> {
81
86
try {
82
87
await _controller.initialize ();
83
88
hasLoaded = true ;
84
- _controller.addListener (videoPlayerListener);
89
+ _controller
90
+ ..addListener (videoPlayerListener)
91
+ ..setLooping (widget.hasOnlyOneVideoAndMoment);
92
+ if (widget.hasOnlyOneVideoAndMoment) {
93
+ _controller.play ();
94
+ }
85
95
} catch (e) {
86
96
realDebugPrint ('Error when initialize video controller: $e ' );
87
97
hasErrorWhenInitializing = true ;
@@ -142,35 +152,39 @@ class _VideoPageBuilderState extends State<VideoPageBuilder> {
142
152
),
143
153
),
144
154
),
145
- ValueListenableBuilder <bool >(
146
- valueListenable: isPlaying,
147
- builder: (_, bool value, __) => GestureDetector (
148
- behavior: HitTestBehavior .opaque,
149
- onTap: value ? playButtonCallback : builder.switchDisplayingDetail,
150
- child: Center (
151
- child: AnimatedOpacity (
152
- duration: kThemeAnimationDuration,
153
- opacity: value ? 0.0 : 1.0 ,
154
- child: GestureDetector (
155
- onTap: playButtonCallback,
156
- child: DecoratedBox (
157
- decoration: const BoxDecoration (
158
- boxShadow: < BoxShadow > [BoxShadow (color: Colors .black12)],
159
- shape: BoxShape .circle,
160
- ),
161
- child: Icon (
162
- value
163
- ? Icons .pause_circle_outline
164
- : Icons .play_circle_filled,
165
- size: 70.0 ,
166
- color: Colors .white,
155
+ if (! widget.hasOnlyOneVideoAndMoment)
156
+ ValueListenableBuilder <bool >(
157
+ valueListenable: isPlaying,
158
+ builder: (_, bool value, __) => GestureDetector (
159
+ behavior: HitTestBehavior .opaque,
160
+ onTap:
161
+ value ? playButtonCallback : builder.switchDisplayingDetail,
162
+ child: Center (
163
+ child: AnimatedOpacity (
164
+ duration: kThemeAnimationDuration,
165
+ opacity: value ? 0.0 : 1.0 ,
166
+ child: GestureDetector (
167
+ onTap: playButtonCallback,
168
+ child: DecoratedBox (
169
+ decoration: const BoxDecoration (
170
+ boxShadow: < BoxShadow > [
171
+ BoxShadow (color: Colors .black12)
172
+ ],
173
+ shape: BoxShape .circle,
174
+ ),
175
+ child: Icon (
176
+ value
177
+ ? Icons .pause_circle_outline
178
+ : Icons .play_circle_filled,
179
+ size: 70.0 ,
180
+ color: Colors .white,
181
+ ),
167
182
),
168
183
),
169
184
),
170
185
),
171
186
),
172
187
),
173
- ),
174
188
],
175
189
);
176
190
}
0 commit comments