回答編集履歴

1

2017/05/14 02:05

投稿

_Kentarou
_Kentarou

スコア8490

test CHANGED
@@ -7,3 +7,37 @@
7
7
  let pianoSoundURL = URL(fileURLWithPath: Bundle.main.path(forResource: key, ofType: "mp3")!)
8
8
 
9
9
  ```
10
+
11
+
12
+
13
+ 追記
14
+
15
+
16
+
17
+ ```swift
18
+
19
+ for key in pianoKeys {
20
+
21
+ let pianoSoundURL = URL(fileURLWithPath: Bundle.main.path(forResource: key, ofType: "mp3")!)
22
+
23
+
24
+
25
+ do {
26
+
27
+
28
+
29
+ let audioPlayer = try AVAudioPlayer(contentsOf: pianoSoundURL)
30
+
31
+ audioPlayer.prepareToPlay()
32
+
33
+ audioPlayers.append(audioPlayer)
34
+
35
+ } catch {
36
+
37
+
38
+
39
+ }
40
+
41
+ }
42
+
43
+ ```