@@ -39,16 +39,7 @@ class AudioHandler extends GetxController {
39
39
final RxList <PlayMusic > playMusicList = RxList <PlayMusic >([]);
40
40
final Rx <PlayMusic ?> playingMusic = Rx <PlayMusic ?>(null );
41
41
final ConcatenatingAudioSource playSourceList =
42
- ConcatenatingAudioSource (children: [
43
- if (Platform .isWindows)
44
- AudioSource .asset (
45
- "assets/nature.mp3" ,
46
- tag: const MediaItem (
47
- title: "Empty" ,
48
- id: 'default' ,
49
- ),
50
- ),
51
- ]);
42
+ ConcatenatingAudioSource (children: []);
52
43
53
44
Future <void > _init () async {
54
45
// 先默认开启所有的循环
@@ -62,7 +53,9 @@ class AudioHandler extends GetxController {
62
53
talker.error ('[PlaybackEventStream Error] $e ' );
63
54
});
64
55
// 将playSourceList交给player作为列表,不过目前是空的
65
- _player.setAudioSource (playSourceList);
56
+ if (! Platform .isWindows) {
57
+ _player.setAudioSource (playSourceList);
58
+ }
66
59
67
60
_player.currentIndexStream.listen ((event) {
68
61
talker.info ("[Music Handler] currentIndexStream updated" );
@@ -76,10 +69,6 @@ class AudioHandler extends GetxController {
76
69
77
70
Future <void > addMusicPlay (DisplayMusic music) async {
78
71
try {
79
- if (Platform .isWindows && isWindowsFirstPlay) {
80
- isWindowsFirstPlay = false ;
81
- await clear ();
82
- }
83
72
PlayMusic ? playMusic;
84
73
var index = - 1 ;
85
74
if (music.info.defaultQuality != null ) {
@@ -105,6 +94,11 @@ class AudioHandler extends GetxController {
105
94
updateRx (music: playMusic);
106
95
await playSourceList.add (playMusic.toAudioSource ());
107
96
97
+ if (Platform .isWindows && isWindowsFirstPlay) {
98
+ await _player.setAudioSource (playSourceList);
99
+ isWindowsFirstPlay = false ;
100
+ }
101
+
108
102
// 播放新的音乐
109
103
await seek (Duration .zero, index: playSourceList.length - 1 );
110
104
@@ -186,16 +180,17 @@ class AudioHandler extends GetxController {
186
180
}
187
181
await clear ();
188
182
189
- if (Platform .isWindows) {
190
- isWindowsFirstPlay = false ;
191
- }
192
-
193
183
var firstMusic = await display2PlayMusic (musics[0 ]);
194
184
if (firstMusic == null ) return ;
195
185
playMusicList.add (firstMusic);
196
186
await playSourceList.add (firstMusic.toAudioSource ());
197
187
updateRx (music: firstMusic);
198
188
189
+ if (Platform .isWindows && isWindowsFirstPlay) {
190
+ await _player.setAudioSource (playSourceList);
191
+ isWindowsFirstPlay = false ;
192
+ }
193
+
199
194
await play ();
200
195
201
196
List <PlayMusic > newPlayMusics = [];
@@ -248,7 +243,6 @@ class AudioHandler extends GetxController {
248
243
}
249
244
if (playSourceList.length > 0 ) {
250
245
await playSourceList.clear ();
251
- update ();
252
246
}
253
247
updateRx ();
254
248
log2List ("Afer Clear all musics" );
0 commit comments