File tree 3 files changed +33
-4
lines changed
3 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,34 @@ class _MyHomePageState extends State<MyHomePage> {
69
69
AudioPlayer _player;
70
70
bool _isPlaying = false ;
71
71
72
+ List <AudioPlayer > _playersList = List <AudioPlayer >();
73
+
74
+
75
+ void _play5 () async {
76
+
77
+ if (_playersList.length != 0 ) {
78
+ for (final player in _playersList)
79
+ player.dispose ();
80
+ }
81
+
82
+ // start 5 players with 250 ms delay in between
83
+ for (int i = 0 ; i < 5 ; ++ i) {
84
+ AudioPlayer player = AudioPlayer (handleInterruptions: true );
85
+ AudioSource audioSource = AudioSource .uri (Uri .parse ("asset:///assets/10-second-audio.m4a" ));
86
+ await player.setAudioSource (audioSource);
87
+ await player.setLoopMode (LoopMode .one);
88
+ await player.play ();
89
+ _playersList.add (player);
90
+ await Future .delayed (Duration (milliseconds: 250 ));
91
+ }
92
+
93
+ // trigger refresh
94
+ setState (() {
95
+ _counter = ++ _counter % 10 ;
96
+ });
97
+ }
98
+
99
+
72
100
73
101
void _playNext () async {
74
102
if (_player != null ) {
@@ -275,7 +303,8 @@ class _MyHomePageState extends State<MyHomePage> {
275
303
),
276
304
),
277
305
floatingActionButton: FloatingActionButton (
278
- onPressed: _playNext,
306
+ onPressed: _play5,
307
+ // onPressed: _playNext,
279
308
// onPressed: _playLoop,
280
309
tooltip: 'Play Next' ,
281
310
child: Icon (Icons .add),
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ packages:
134
134
name: just_audio
135
135
url: "https://pub.dartlang.org"
136
136
source: hosted
137
- version: "0.6.5 "
137
+ version: "0.6.9 "
138
138
just_audio_platform_interface:
139
139
dependency: transitive
140
140
description:
@@ -148,7 +148,7 @@ packages:
148
148
name: just_audio_web
149
149
url: "https://pub.dartlang.org"
150
150
source: hosted
151
- version: "0.2.1 "
151
+ version: "0.2.3 "
152
152
matcher:
153
153
dependency: transitive
154
154
description:
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ dependencies:
31
31
# Use with the CupertinoIcons class for iOS style icons.
32
32
cupertino_icons : ^1.0.0
33
33
path_provider : ^1.6.24
34
- just_audio : ^0.6.5
34
+ just_audio : ^0.6.9
35
35
# just_audio:
36
36
# git:
37
37
# # url: https://github.com/ryanheise/just_audio.git
You can’t perform that action at this time.
0 commit comments