@@ -13,19 +13,11 @@ class TencentPlayerController extends ValueNotifier<TencentPlayerValue> {
13
13
MethodChannel channel = TencentPlayer .channel;
14
14
15
15
16
- TencentPlayerController .asset (this .dataSource,
17
- {this .playerConfig = const PlayerConfig ()})
18
- : dataSourceType = DataSourceType .asset,
19
- super (TencentPlayerValue ());
16
+ TencentPlayerController .asset (this .dataSource, {this .playerConfig = const PlayerConfig ()}): dataSourceType = DataSourceType .asset, super (TencentPlayerValue ());
20
17
21
- TencentPlayerController .network (this .dataSource, {this .playerConfig = const PlayerConfig ()}): dataSourceType = DataSourceType .network,
22
- super (TencentPlayerValue ());
18
+ TencentPlayerController .network (this .dataSource, {this .playerConfig = const PlayerConfig ()}): dataSourceType = DataSourceType .network, super (TencentPlayerValue ());
23
19
24
- TencentPlayerController .file (String filePath,
25
- {this .playerConfig = const PlayerConfig ()})
26
- : dataSource = filePath,
27
- dataSourceType = DataSourceType .file,
28
- super (TencentPlayerValue ());
20
+ TencentPlayerController .file (String filePath, {this .playerConfig = const PlayerConfig ()}): dataSource = filePath, dataSourceType = DataSourceType .file, super (TencentPlayerValue ());
29
21
30
22
bool _isDisposed = false ;
31
23
Completer <void > _creatingCompleter;
@@ -51,8 +43,7 @@ class TencentPlayerController extends ValueNotifier<TencentPlayerValue> {
51
43
}
52
44
value = value.copyWith (isPlaying: playerConfig.autoPlay);
53
45
dataSourceDescription.addAll (playerConfig.toJson ());
54
- final Map <String , dynamic > response =
55
- await channel.invokeMapMethod <String , dynamic >(
46
+ final Map <String , dynamic > response = await channel.invokeMapMethod <String , dynamic >(
56
47
'create' ,
57
48
dataSourceDescription,
58
49
);
@@ -99,9 +90,7 @@ class TencentPlayerController extends ValueNotifier<TencentPlayerValue> {
99
90
}
100
91
}
101
92
102
- _eventSubscription = _eventChannelFor (_textureId)
103
- .receiveBroadcastStream ()
104
- .listen (eventListener);
93
+ _eventSubscription = _eventChannelFor (_textureId).receiveBroadcastStream ().listen (eventListener);
105
94
return initializingCompleter.future;
106
95
}
107
96
@@ -136,15 +125,14 @@ class TencentPlayerController extends ValueNotifier<TencentPlayerValue> {
136
125
}
137
126
138
127
Future <void > _applyPlayPause () async {
139
- if (! value.initialized || _isDisposed) {
140
- return ;
141
- }
128
+ // if (!value.initialized || _isDisposed) {
129
+ // if (!value.initialized) {
130
+ // return;
131
+ // }
142
132
if (value.isPlaying) {
143
- await channel
144
- .invokeMethod ('play' , < String , dynamic > {'textureId' : _textureId});
133
+ await channel.invokeMethod ('play' , < String , dynamic > {'textureId' : _textureId});
145
134
} else {
146
- await channel
147
- .invokeMethod ('pause' , < String , dynamic > {'textureId' : _textureId});
135
+ await channel.invokeMethod ('pause' , < String , dynamic > {'textureId' : _textureId});
148
136
}
149
137
}
150
138
@@ -197,6 +185,7 @@ class TencentPlayerController extends ValueNotifier<TencentPlayerValue> {
197
185
}
198
186
}
199
187
188
+ ///视频组件生命周期监听
200
189
class _VideoAppLifeCycleObserver with WidgetsBindingObserver {
201
190
bool _wasPlayingBeforePause = false ;
202
191
final TencentPlayerController _controller;
0 commit comments