質問編集履歴
8
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -108,7 +108,7 @@
|
|
108
108
|
|
109
109
|
|
110
110
|
|
111
|
-
func audioPlayerDidFinishPlaying(_ player
|
111
|
+
func audioPlayerDidFinishPlaying(_ player: AVAudioPlayer, successfully flag: Bool) {
|
112
112
|
|
113
113
|
player2.play()
|
114
114
|
|
7
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -63,3 +63,55 @@
|
|
63
63
|
|
64
64
|
|
65
65
|
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
訂正
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
func player2(url: URL, url2: URL) {
|
78
|
+
|
79
|
+
do {
|
80
|
+
|
81
|
+
try player = AVAudioPlayer(contentsOf:url)
|
82
|
+
|
83
|
+
try player2 = AVAudioPlayer(contentsOf: url2)
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
player.prepareToPlay()
|
88
|
+
|
89
|
+
player.delegate = self
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
} catch {
|
94
|
+
|
95
|
+
print(error)
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
@IBAction func pushButton3(sender: UIButton) {
|
104
|
+
|
105
|
+
player2(url: url1, url2: url2)
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
func audioPlayerDidFinishPlaying(_ player2: AVAudioPlayer, successfully flag: Bool) {
|
112
|
+
|
113
|
+
player2.play()
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
```
|
6
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
複数のオーディオファイルを
|
1
|
+
複数のオーディオファイルを順番に再生するコードをswiftで書きたいのですが、以下の文では二つ同時に再生されてしまいます。どのように書き換えればよいでしょうか。
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
@IBAction func pushButton3(sender: UIButton) { play(url: url) play(url: url2) }
|
6
2
|
|
7
3
|
|
8
4
|
|
@@ -28,63 +24,41 @@
|
|
28
24
|
|
29
25
|
|
30
26
|
|
31
|
-
let url = Bundle.main.bundleURL.appendingPathComponent("
|
27
|
+
let url = Bundle.main.bundleURL.appendingPathComponent("audio1.mp3")
|
32
28
|
|
33
|
-
let url2 = Bundle.main.bundleURL.appendingPathComponent("
|
29
|
+
let url2 = Bundle.main.bundleURL.appendingPathComponent("audio2.mp3")
|
34
30
|
|
35
31
|
|
36
32
|
|
33
|
+
func player2(url: URL, url2: URL){
|
34
|
+
|
35
|
+
do {
|
36
|
+
|
37
|
+
try player = AVAudioPlayer(contentsOf: url)
|
38
|
+
|
39
|
+
try player2 = AVAudioPlayer(contentsOf: url2)
|
40
|
+
|
41
|
+
player.play()
|
42
|
+
|
43
|
+
player2.play()
|
37
44
|
|
38
45
|
|
39
46
|
|
47
|
+
} catch {
|
40
48
|
|
41
|
-
|
49
|
+
print(error)
|
42
50
|
|
43
|
-
|
51
|
+
}
|
44
52
|
|
45
|
-
super.viewDidLoad()
|
46
|
-
|
47
|
-
|
53
|
+
}
|
48
54
|
|
49
55
|
|
50
56
|
|
51
|
-
|
57
|
+
@IBAction func playbutton1(_ sender: Any) {
|
52
58
|
|
53
|
-
|
59
|
+
player2(url: url1, url2: url2)
|
54
60
|
|
55
|
-
try player = AVAudioPlayer(contentsOf:url)
|
56
|
-
|
57
|
-
player.play()
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
} catch {
|
62
|
-
|
63
|
-
print(error)
|
64
|
-
|
65
|
-
|
61
|
+
}
|
66
|
-
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@IBAction func pushButton3(sender: UIButton) {
|
74
|
-
|
75
|
-
func pushButton1(sender: UIButton) {
|
76
|
-
|
77
|
-
play(url: url)
|
78
|
-
|
79
|
-
}
|
80
|
-
|
81
|
-
func pushButton2(sender: UIButton) {
|
82
|
-
|
83
|
-
play(url: url2)
|
84
|
-
|
85
|
-
}
|
86
|
-
|
87
|
-
}
|
88
62
|
|
89
63
|
|
90
64
|
|
5
訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
|
29
|
+
|
30
30
|
|
31
31
|
let url = Bundle.main.bundleURL.appendingPathComponent("もう三日.mp3")
|
32
32
|
|
@@ -68,27 +68,7 @@
|
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
-
|
71
|
+
|
72
|
-
|
73
|
-
@IBAction func pushButton1(sender: UIButton) {
|
74
|
-
|
75
|
-
play(url: url)
|
76
|
-
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
//再生ボタン2押下時の呼び出しメソッド
|
82
|
-
|
83
|
-
@IBAction func pushButton2(sender: UIButton) {
|
84
|
-
|
85
|
-
play(url: url2)
|
86
|
-
|
87
|
-
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
//再生ボタン3押下時の呼び出しメソッド
|
92
72
|
|
93
73
|
@IBAction func pushButton3(sender: UIButton) {
|
94
74
|
|
4
訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,9 +10,7 @@
|
|
10
10
|
|
11
11
|
全文
|
12
12
|
|
13
|
-
``
|
13
|
+
```
|
14
|
-
|
15
|
-
|
16
14
|
|
17
15
|
import UIKit
|
18
16
|
|
@@ -110,4 +108,4 @@
|
|
110
108
|
|
111
109
|
|
112
110
|
|
113
|
-
``
|
111
|
+
```
|
3
````
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,6 +11,8 @@
|
|
11
11
|
全文
|
12
12
|
|
13
13
|
``
|
14
|
+
|
15
|
+
|
14
16
|
|
15
17
|
import UIKit
|
16
18
|
|
@@ -106,4 +108,6 @@
|
|
106
108
|
|
107
109
|
}
|
108
110
|
|
111
|
+
|
112
|
+
|
109
113
|
``
|
2
``追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
全文
|
12
12
|
|
13
|
-
|
13
|
+
``
|
14
14
|
|
15
15
|
import UIKit
|
16
16
|
|
@@ -106,4 +106,4 @@
|
|
106
106
|
|
107
107
|
}
|
108
108
|
|
109
|
-
|
109
|
+
``
|
1
""を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,6 +9,8 @@
|
|
9
9
|
|
10
10
|
|
11
11
|
全文
|
12
|
+
|
13
|
+
"
|
12
14
|
|
13
15
|
import UIKit
|
14
16
|
|
@@ -103,3 +105,5 @@
|
|
103
105
|
}
|
104
106
|
|
105
107
|
}
|
108
|
+
|
109
|
+
"
|