teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

コードの挿入

2021/12/05 18:58

投稿

bump_of_pool
bump_of_pool

スコア7

title CHANGED
@@ -1,1 +1,1 @@
1
- processingで音楽プレーヤーを作成したいです。
1
+ processingで音楽プレーヤーのスキップ機能を作成したいです。
body CHANGED
File without changes

2

コードの挿入

2021/12/05 18:58

投稿

bump_of_pool
bump_of_pool

スコア7

title CHANGED
@@ -1,1 +1,1 @@
1
- processingで音楽の再生ができなくなりました。
1
+ processingで音楽プレーヤーを作成したいです
body CHANGED
@@ -1,6 +1,5 @@
1
- ![イメージ説明](4e44925059f7a1a868f229446956dbe6.png)
2
1
  音楽プレーヤーのようなものを作成していました。
3
- のようなコードで音楽を再生していたのですが急に再生ができなくなりました。バージョンは、3.5.3です。これに曲のスキップ機能をつけたいと思っております。ボタン作成方法が分からず困っています。どなたかご教授ください。
2
+ これに曲のスキップ機能をつけたいと思っております。マウスでクリックしたときに次曲または前曲を再生する方法が分からず困っています。どなたかご教授ください。
4
3
  全体のプログラムは以下の通りです。
5
4
 
6
5
  ```ここに言語を入力
@@ -17,41 +16,96 @@
17
16
 
18
17
  PImage img;
19
18
  Minim minim;
20
- AudioPlayer player;
19
+ AudioPlayer player1;
20
+ AudioPlayer player2;
21
+ AudioPlayer player3;
22
+ AudioPlayer player4;
23
+ AudioPlayer player5;
24
+ Teishi teishi;
25
+ Saisei saisei;
21
26
 
27
+
28
+
22
29
  void setup(){
23
30
  size(357, 600);
24
31
  PFont font = createFont("Meiryo",50);
25
32
  textFont(font);
26
33
  img = loadImage("586.jpg");
27
34
  minim = new Minim(this);
35
+ teishi = new Teishi();
36
+ saisei = new Saisei();
28
- player = minim.loadFile("01 Pale Blue.wav");
37
+ player1 = minim.loadFile("01 Tides.mp3");
29
- fill(0);
38
+ player2 = minim.loadFile("02 Shivers.mp3");
39
+ player3 = minim.loadFile("03 First Times.mp3");
30
- triangle(a,b,a,b+30,a+30,b+15);
40
+ player4 = minim.loadFile("04 Bad Habits.mp3");
41
+ player5 = minim.loadFile("05 Overpass Graffiti.mp3");
42
+ saisei.display();
31
43
  }
32
44
 
33
45
  void draw(){
46
+ }
47
+
48
+ void mouseClicked(){
49
+ if (a-1 < mouseX && mouseX < a + 30 && b-1 < mouseY && mouseY < b + 30) {
50
+ saisei.display();
51
+ if (player4.isPlaying()) {
52
+ player4.pause();
53
+ } else {
54
+ player4.loop();
55
+ teishi.display();
56
+ }
57
+ }
58
+
59
+ }
60
+
61
+ class Saisei{
62
+ void display(){
63
+ background(255);
34
- image(img, width*1.17/7, height/12, width*2/3, height*2/5);
64
+ image(img, width*1.17/7, height/12, width*2/3, height*2/5);
65
+ strokeWeight(5);
35
66
  line(0, (height*3/5)-10, width, (height*3/5)-10);
36
- strokeWeight(5);
37
67
  fill(0);
38
68
  textSize(30);
39
69
  text("曲名", 40, 400);
40
70
  textSize(15);
41
71
  text("artist", 40, 425);
42
72
  text("1/1",width/2-10, height/2+30);
43
-
73
+ fill(255);
44
-
74
+ rect(b,a,b,a);
75
+ fill(0);
76
+ triangle(a,b,a,b+30,a+30,b+15);
77
+
78
+ triangle(200,425,215,415,215,435);
79
+ triangle(218,425,233,415,233,435);
80
+
81
+ triangle(300,425,285,415,285,435);
82
+ triangle(318,425,303,415,303,435);
83
+ }
45
84
  }
85
+
46
-
86
+ class Teishi{
47
- void mouseClicked(){
87
+ void display(){
48
- if (a < mouseX && mouseX < a + 30 && b < mouseY && mouseY < b + 15) {
49
- if (player.isPlaying()) {
50
- player.pause();
88
+ background(255);
51
- } else {
89
+ image(img, width*1.17/7, height/12, width*2/3, height*2/5);
52
- player.loop();
90
+ strokeWeight(5);
91
+ line(0, (height*3/5)-10, width, (height*3/5)-10);
53
- }
92
+ fill(0);
93
+ textSize(30);
94
+ text("曲名", 40, 400);
95
+ textSize(15);
96
+ text("artist", 40, 425);
97
+ text("1/1",width/2-10, height/2+30);
98
+ fill(255);
99
+ rect(b,a,b,a);
100
+ fill(0);
101
+ line(a,b,a,b+30);
102
+ line(a+15,b,a+15,b+30);
103
+
104
+ triangle(200,425,215,415,215,435);
105
+ triangle(218,425,233,415,233,435);
106
+
107
+ triangle(300,425,285,415,285,435);
108
+ triangle(318,425,303,415,303,435);
54
109
  }
55
110
  }
56
-
57
111
  ```

1

コードの挿入

2021/12/05 18:50

投稿

bump_of_pool
bump_of_pool

スコア7

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,7 @@
3
3
  このようなコードで音楽を再生していたのですが急に再生ができなくなりました。バージョンは、3.5.3です。これに曲のスキップ機能をつけたいと思っております。そのボタンの作成方法が分からず困っています。どなたかご教授ください。
4
4
  全体のプログラムは以下の通りです。
5
5
 
6
-
6
+ ```ここに言語を入力
7
7
  import ddf.minim.*;
8
8
  import ddf.minim.analysis.*;
9
9
  import ddf.minim.effects.*;
@@ -52,4 +52,6 @@
52
52
  player.loop();
53
53
  }
54
54
  }
55
- }
55
+ }
56
+
57
+ ```