質問編集履歴
3
追加コード
test
CHANGED
File without changes
|
test
CHANGED
@@ -50,6 +50,404 @@
|
|
50
50
|
|
51
51
|
```
|
52
52
|
|
53
|
+
###作成中のform全体
|
54
|
+
|
55
|
+
```
|
56
|
+
|
57
|
+
Imports System.IO
|
58
|
+
|
59
|
+
Imports System
|
60
|
+
|
61
|
+
Public Class Music00b
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
Private history As New HashSet(Of String)(StringComparer.OrdinalIgnoreCase)
|
66
|
+
|
67
|
+
Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
|
68
|
+
|
69
|
+
Dim files = OpenFileDialog1.FileNames
|
70
|
+
|
71
|
+
Dim conflict = files.Where(AddressOf history.Contains)
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
If conflict.Any() Then
|
76
|
+
|
77
|
+
e.Cancel = True
|
78
|
+
|
79
|
+
Dim fileNames = conflict.Select(AddressOf System.IO.Path.GetFileName)
|
80
|
+
|
81
|
+
MessageBox.Show("同じファイルがあります。" & vbCrLf & String.Join(vbCrLf, fileNames), "競合", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
82
|
+
|
83
|
+
Else
|
84
|
+
|
85
|
+
Array.ForEach(files, AddressOf history.Add)
|
86
|
+
|
87
|
+
End If
|
88
|
+
|
89
|
+
End Sub
|
90
|
+
|
91
|
+
Private Sub Music00b_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
92
|
+
|
93
|
+
AxWindowsMediaPlayer2.Hide()
|
94
|
+
|
95
|
+
TextBox1.ReadOnly = True
|
96
|
+
|
97
|
+
TextBox2.ReadOnly = True
|
98
|
+
|
99
|
+
TextBox3.ReadOnly = True
|
100
|
+
|
101
|
+
TextBox2.ReadOnly = True
|
102
|
+
|
103
|
+
PictureBox1.Enabled = False
|
104
|
+
|
105
|
+
PictureBox2.Enabled = False
|
106
|
+
|
107
|
+
PictureBox3.Enabled = False
|
108
|
+
|
109
|
+
PictureBox4.Enabled = False
|
110
|
+
|
111
|
+
PictureBox5.Enabled = False
|
112
|
+
|
113
|
+
ListBox2.Hide()
|
114
|
+
|
115
|
+
Label1.Hide()
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
End Sub
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
124
|
+
|
125
|
+
ProgressBar1.Value = 0
|
126
|
+
|
127
|
+
TextBox2.Text = TimeSpan.FromSeconds(AxWindowsMediaPlayer2.Ctlcontrols.currentPosition).ToString("mm\:ss")
|
128
|
+
|
129
|
+
Me.Timer1.Enabled = False
|
130
|
+
|
131
|
+
Me.Timer2.Enabled = True
|
132
|
+
|
133
|
+
End Sub
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
|
138
|
+
|
139
|
+
Dim length As Integer
|
140
|
+
|
141
|
+
Dim current As Integer
|
142
|
+
|
143
|
+
length = If(AxWindowsMediaPlayer2.currentMedia?.duration, 0)
|
144
|
+
|
145
|
+
current = AxWindowsMediaPlayer2.Ctlcontrols.currentPosition
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
ProgressBar1.Value = current
|
150
|
+
|
151
|
+
ProgressBar1.Maximum = length
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
If ProgressBar1.Value = 100 Then
|
156
|
+
|
157
|
+
ProgressBar1.Value = 0
|
158
|
+
|
159
|
+
End If
|
160
|
+
|
161
|
+
End Sub
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
|
166
|
+
|
167
|
+
TextBox2.Text = TimeSpan.FromSeconds(AxWindowsMediaPlayer2.Ctlcontrols.currentPosition).ToString("mm\:ss")
|
168
|
+
|
169
|
+
End Sub
|
170
|
+
|
171
|
+
Dim Open00a As String()
|
172
|
+
|
173
|
+
Dim file As String()
|
174
|
+
|
175
|
+
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
176
|
+
|
177
|
+
AxWindowsMediaPlayer2.settings.autoStart = False
|
178
|
+
|
179
|
+
OpenFileDialog1.FileName = ""
|
180
|
+
|
181
|
+
OpenFileDialog1.Multiselect = True
|
182
|
+
|
183
|
+
OpenFileDialog1.Title = "開くファイルを指定"
|
184
|
+
|
185
|
+
OpenFileDialog1.Filter = "MP3(*.mp3)|*.mp3|全てのファイル (*.*)|*.*"
|
186
|
+
|
187
|
+
OpenFileDialog1.FilterIndex = 1
|
188
|
+
|
189
|
+
OpenFileDialog1.RestoreDirectory = True
|
190
|
+
|
191
|
+
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
|
192
|
+
|
193
|
+
file = OpenFileDialog1.SafeFileNames
|
194
|
+
|
195
|
+
Open00a = OpenFileDialog1.FileNames
|
196
|
+
|
197
|
+
For b As Integer = 0 To file.Length - 1
|
198
|
+
|
199
|
+
ListBox2.Items.Add(file(b))
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
AxWindowsMediaPlayer2.currentPlaylist.appendItem(AxWindowsMediaPlayer2.newMedia(b))
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
Next
|
208
|
+
|
209
|
+
ListBox2.SelectedIndex = 0
|
210
|
+
|
211
|
+
TextBox1.Text = System.IO.Path.GetFileName(ListBox2.SelectedItem)
|
212
|
+
|
213
|
+
End If
|
214
|
+
|
215
|
+
End Sub
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
220
|
+
|
221
|
+
'全てクリアされる
|
222
|
+
|
223
|
+
history.Clear()
|
224
|
+
|
225
|
+
ListBox2.Items.Clear()
|
226
|
+
|
227
|
+
TextBox1.Clear()
|
228
|
+
|
229
|
+
TextBox2.Clear()
|
230
|
+
|
231
|
+
TextBox3.Clear()
|
232
|
+
|
233
|
+
Button2.Enabled = True
|
234
|
+
|
235
|
+
AxWindowsMediaPlayer2.Ctlcontrols.stop()
|
236
|
+
|
237
|
+
AxWindowsMediaPlayer2.currentPlaylist.clear()
|
238
|
+
|
239
|
+
Timer1.Stop()
|
240
|
+
|
241
|
+
Timer2.Stop()
|
242
|
+
|
243
|
+
Timer3.Stop()
|
244
|
+
|
245
|
+
ProgressBar1.Value = 0
|
246
|
+
|
247
|
+
MessageBox.Show("リストクリアーしました。",
|
248
|
+
|
249
|
+
"報告",
|
250
|
+
|
251
|
+
MessageBoxButtons.OK,
|
252
|
+
|
253
|
+
MessageBoxIcon.Asterisk)
|
254
|
+
|
255
|
+
End Sub
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
AxWindowsMediaPlayer2.Ctlcontrols.play()
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
TextBox1.Text = System.IO.Path.GetFileName(ListBox2.SelectedItem)
|
268
|
+
|
269
|
+
Timer1.Start()
|
270
|
+
|
271
|
+
Timer2.Start()
|
272
|
+
|
273
|
+
Timer1.Enabled = True
|
274
|
+
|
275
|
+
End Sub
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
|
280
|
+
|
281
|
+
AxWindowsMediaPlayer2.Ctlcontrols.pause()
|
282
|
+
|
283
|
+
End Sub
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
|
288
|
+
|
289
|
+
AxWindowsMediaPlayer2.Ctlcontrols.stop()
|
290
|
+
|
291
|
+
ProgressBar1.Value = 0
|
292
|
+
|
293
|
+
End Sub
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
Private Sub PictureBox4_Click(sender As Object, e As EventArgs) Handles PictureBox4.Click
|
298
|
+
|
299
|
+
Try
|
300
|
+
|
301
|
+
ListBox2.SelectedIndex += -1
|
302
|
+
|
303
|
+
AxWindowsMediaPlayer2.Ctlcontrols.previous()
|
304
|
+
|
305
|
+
AxWindowsMediaPlayer2.Ctlcontrols.play()
|
306
|
+
|
307
|
+
ProgressBar1.Value = 0
|
308
|
+
|
309
|
+
Timer1.Start()
|
310
|
+
|
311
|
+
Timer2.Start()
|
312
|
+
|
313
|
+
Catch ex As Exception
|
314
|
+
|
315
|
+
MessageBox.Show("曲がありません",
|
316
|
+
|
317
|
+
"エラー",
|
318
|
+
|
319
|
+
MessageBoxButtons.OK,
|
320
|
+
|
321
|
+
MessageBoxIcon.Asterisk)
|
322
|
+
|
323
|
+
AxWindowsMediaPlayer2.Ctlcontrols.stop()
|
324
|
+
|
325
|
+
Timer1.Stop()
|
326
|
+
|
327
|
+
Timer2.Stop()
|
328
|
+
|
329
|
+
End Try
|
330
|
+
|
331
|
+
End Sub
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
Private Sub PictureBox5_Click(sender As Object, e As EventArgs) Handles PictureBox5.Click
|
336
|
+
|
337
|
+
Try
|
338
|
+
|
339
|
+
ListBox2.SelectedIndex += +1
|
340
|
+
|
341
|
+
AxWindowsMediaPlayer2.Ctlcontrols.next()
|
342
|
+
|
343
|
+
AxWindowsMediaPlayer2.Ctlcontrols.play()
|
344
|
+
|
345
|
+
ProgressBar1.Value = 0
|
346
|
+
|
347
|
+
Timer1.Start()
|
348
|
+
|
349
|
+
Timer2.Start()
|
350
|
+
|
351
|
+
Catch ex As Exception
|
352
|
+
|
353
|
+
MessageBox.Show("曲がありません",
|
354
|
+
|
355
|
+
"エラー",
|
356
|
+
|
357
|
+
MessageBoxButtons.OK,
|
358
|
+
|
359
|
+
MessageBoxIcon.Asterisk)
|
360
|
+
|
361
|
+
End Try
|
362
|
+
|
363
|
+
End Sub
|
364
|
+
|
365
|
+
Private Sub HScrollBar1_Scroll(sender As Object, e As ScrollEventArgs) Handles HScrollBar1.Scroll
|
366
|
+
|
367
|
+
AxWindowsMediaPlayer2.settings.volume = HScrollBar1.Value
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
Lb2.Text = "" & HScrollBar1.Value
|
372
|
+
|
373
|
+
End Sub
|
374
|
+
|
375
|
+
Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As System.Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer2.PlayStateChange
|
376
|
+
|
377
|
+
Try
|
378
|
+
|
379
|
+
Dim wa As Integer
|
380
|
+
|
381
|
+
wa = ListBox2.SelectedIndex
|
382
|
+
|
383
|
+
If AxWindowsMediaPlayer2.currentMedia.isIdentical(AxWindowsMediaPlayer2.currentPlaylist.Item(wa)) Then
|
384
|
+
|
385
|
+
End If
|
386
|
+
|
387
|
+
Timer1.Start()
|
388
|
+
|
389
|
+
Timer2.Start()
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
ProgressBar1.Value = 0
|
394
|
+
|
395
|
+
Catch ex As Exception
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
End Try
|
400
|
+
|
401
|
+
Select Case e.newState
|
402
|
+
|
403
|
+
Case WMPLib.WMPPlayState.wmppsPlaying '再生中
|
404
|
+
|
405
|
+
TextBox3.Text = AxWindowsMediaPlayer2.currentMedia.durationString
|
406
|
+
|
407
|
+
Timer3.Start()
|
408
|
+
|
409
|
+
ProgressBar1.Maximum = AxWindowsMediaPlayer2.currentMedia.duration
|
410
|
+
|
411
|
+
ProgressBar1.Value = 0
|
412
|
+
|
413
|
+
Case e.newState = WMPLib.WMPPlayState.wmppsMediaEnded '再生終了
|
414
|
+
|
415
|
+
Timer3.Stop()
|
416
|
+
|
417
|
+
ProgressBar1.Value = 0
|
418
|
+
|
419
|
+
Case WMPLib.WMPPlayState.wmppsMediaEnded
|
420
|
+
|
421
|
+
' 再生が全て終了した時()
|
422
|
+
|
423
|
+
AxWindowsMediaPlayer2.Ctlcontrols.stop()
|
424
|
+
|
425
|
+
Case Else
|
426
|
+
|
427
|
+
Debug.Print(e.newState.ToString())
|
428
|
+
|
429
|
+
End Select
|
430
|
+
|
431
|
+
End Sub
|
432
|
+
|
433
|
+
Private Sub ListBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox2.SelectedIndexChanged
|
434
|
+
|
435
|
+
If ListBox2.SelectedItem <> "" Then
|
436
|
+
|
437
|
+
AxWindowsMediaPlayer2.URL = Open00a(ListBox2.SelectedIndex)
|
438
|
+
|
439
|
+
TextBox1.Text = System.IO.Path.GetFileName(ListBox2.SelectedItem)
|
440
|
+
|
441
|
+
AxWindowsMediaPlayer2.Ctlcontrols.play()
|
442
|
+
|
443
|
+
End If
|
444
|
+
|
445
|
+
End Sub
|
446
|
+
|
447
|
+
End Class
|
448
|
+
|
449
|
+
```
|
450
|
+
|
53
451
|
###試した結果
|
54
452
|
|
55
453
|
前の曲に戻ると2回押さないとメッセージボックスが出ます。
|
2
音楽プレイヤーでリストボックスの前の曲に
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
音楽プレイヤーでリストボックス
|
1
|
+
音楽プレイヤーでリストボックスの前の曲に
|
test
CHANGED
@@ -1,434 +1,18 @@
|
|
1
|
-
### 音楽プレイヤーでリストボックス
|
1
|
+
### 音楽プレイヤーでリストボックスの曲に戻る時におかしくなります
|
2
2
|
|
3
3
|
|
4
4
|
|
5
5
|
初めまして質問させていただきます。
|
6
6
|
|
7
|
-
音楽プレイヤーを
|
7
|
+
音楽プレイヤーを作ってます。
|
8
8
|
|
9
|
-
|
9
|
+
リストボックスで前の曲に戻る時おかしくなりました。
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
以下のコードを貼り付けます。
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
プロジェクト名:usercontrol:Music00b.vb
|
18
|
-
|
19
|
-
Form1にusercontrolを追加しています。
|
20
|
-
|
21
|
-
### ソースコード
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
```VB
|
26
|
-
|
27
|
-
Imports System.IO
|
28
|
-
|
29
|
-
Imports System
|
30
|
-
|
31
|
-
Public Class Music00b
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
Private history As New HashSet(Of String)(StringComparer.OrdinalIgnoreCase)
|
36
|
-
|
37
|
-
Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
|
38
|
-
|
39
|
-
Dim files = OpenFileDialog1.FileNames
|
40
|
-
|
41
|
-
Dim conflict = files.Where(AddressOf history.Contains)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
If conflict.Any() Then
|
46
|
-
|
47
|
-
e.Cancel = True
|
48
|
-
|
49
|
-
Dim fileNames = conflict.Select(AddressOf System.IO.Path.GetFileName)
|
50
|
-
|
51
|
-
MessageBox.Show("同じファイルがあります。" & vbCrLf & String.Join(vbCrLf, fileNames), "競合", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
52
|
-
|
53
|
-
Else
|
54
|
-
|
55
|
-
Array.ForEach(files, AddressOf history.Add)
|
56
|
-
|
57
|
-
End If
|
58
|
-
|
59
|
-
End Sub
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
64
|
-
|
65
|
-
ProgressBar1.Value = 0
|
66
|
-
|
67
|
-
TextBox2.Text = TimeSpan.FromSeconds(AxWindowsMediaPlayer2.Ctlcontrols.currentPosition).ToString("mm\:ss")
|
68
|
-
|
69
|
-
Me.Timer1.Enabled = False
|
70
|
-
|
71
|
-
Me.Timer2.Enabled = True
|
72
|
-
|
73
|
-
End Sub
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
|
78
|
-
|
79
|
-
Dim length As Integer
|
80
|
-
|
81
|
-
Dim current As Integer
|
82
|
-
|
83
|
-
length = If(AxWindowsMediaPlayer2.currentMedia?.duration, 0)
|
84
|
-
|
85
|
-
current = AxWindowsMediaPlayer2.Ctlcontrols.currentPosition
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
ProgressBar1.Value = current
|
90
|
-
|
91
|
-
ProgressBar1.Maximum = length
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
If ProgressBar1.Value = 100 Then
|
96
|
-
|
97
|
-
ProgressBar1.Value = 0
|
98
|
-
|
99
|
-
End If
|
100
|
-
|
101
|
-
End Sub
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
|
106
|
-
|
107
|
-
TextBox2.Text = TimeSpan.FromSeconds(AxWindowsMediaPlayer2.Ctlcontrols.currentPosition).ToString("mm\:ss")
|
108
|
-
|
109
|
-
End Sub
|
110
|
-
|
111
|
-
Dim Open00a As String()
|
112
|
-
|
113
|
-
Dim file As String()
|
114
|
-
|
115
|
-
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
116
|
-
|
117
|
-
AxWindowsMediaPlayer2.settings.autoStart = False
|
118
|
-
|
119
|
-
OpenFileDialog1.FileName = ""
|
120
|
-
|
121
|
-
OpenFileDialog1.Multiselect = True
|
122
|
-
|
123
|
-
OpenFileDialog1.Title = "開くファイルを指定"
|
124
|
-
|
125
|
-
OpenFileDialog1.Filter = "MP3(*.mp3)|*.mp3|Windows Media(*.wma;*.wmv;*.wm)|*.wma;*.wmv;*.wm|Windows Media meta file(*.asx;*.wax;*.wvx;*.wmx)|*.asx;*.wax:*.wvx;*.wmx|MIDI(*.mid;*.midi)|*.mid;*.midi|Windows Auido(*.wav)|*.wav|
|
126
|
-
|
127
|
-
全てのファイル (*.*)|*.*"
|
128
|
-
|
129
|
-
OpenFileDialog1.FilterIndex = 1
|
130
|
-
|
131
|
-
OpenFileDialog1.RestoreDirectory = True
|
132
|
-
|
133
|
-
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
|
134
|
-
|
135
|
-
file = OpenFileDialog1.SafeFileNames
|
136
|
-
|
137
|
-
Open00a = OpenFileDialog1.FileNames
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
For b As Integer = 0 To file.Length - 1
|
142
|
-
|
143
|
-
ListBox2.Items.Add(file(b))
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
AxWindowsMediaPlayer2.currentPlaylist.appendItem(AxWindowsMediaPlayer2.newMedia(b))
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
Next
|
152
|
-
|
153
|
-
ListBox2.SelectedIndex = 0
|
154
|
-
|
155
|
-
TextBox1.Text = System.IO.Path.GetFileName(ListBox2.SelectedItem)
|
156
|
-
|
157
|
-
End If
|
158
|
-
|
159
|
-
End Sub
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
|
164
|
-
|
165
|
-
'全てクリアされる
|
166
|
-
|
167
|
-
history.Clear()
|
168
|
-
|
169
|
-
ListBox2.Items.Clear()
|
170
|
-
|
171
|
-
TextBox1.Clear()
|
172
|
-
|
173
|
-
TextBox2.Clear()
|
174
|
-
|
175
|
-
TextBox3.Clear()
|
176
|
-
|
177
|
-
Button2.Enabled = True
|
178
|
-
|
179
|
-
AxWindowsMediaPlayer2.Ctlcontrols.stop()
|
180
|
-
|
181
|
-
AxWindowsMediaPlayer2.currentPlaylist.clear()
|
182
|
-
|
183
|
-
Timer1.Stop()
|
184
|
-
|
185
|
-
Timer2.Stop()
|
186
|
-
|
187
|
-
Timer3.Stop()
|
188
|
-
|
189
|
-
ProgressBar1.Value = 0
|
190
|
-
|
191
|
-
MessageBox.Show("リストクリアーしました。",
|
192
|
-
|
193
|
-
"報告",
|
194
|
-
|
195
|
-
MessageBoxButtons.OK,
|
196
|
-
|
197
|
-
MessageBoxIcon.Asterisk)
|
198
|
-
|
199
|
-
End Sub
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
AxWindowsMediaPlayer2.Ctlcontrols.play()
|
208
|
-
|
209
|
-
TextBox1.Text = System.IO.Path.GetFileName(ListBox2.SelectedItem)
|
210
|
-
|
211
|
-
Timer1.Start()
|
212
|
-
|
213
|
-
Timer2.Start()
|
214
|
-
|
215
|
-
Timer1.Enabled = True
|
216
|
-
|
217
|
-
End Sub
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
|
222
|
-
|
223
|
-
AxWindowsMediaPlayer2.Ctlcontrols.pause()
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
End Sub
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
|
232
|
-
|
233
|
-
AxWindowsMediaPlayer2.Ctlcontrols.stop()
|
234
|
-
|
235
|
-
ProgressBar1.Value = 0
|
236
|
-
|
237
|
-
End Sub
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
Private Sub PictureBox4_Click(sender As Object, e As EventArgs) Handles PictureBox4.Click
|
242
|
-
|
243
|
-
Try
|
244
|
-
|
245
|
-
ListBox2.SelectedIndex += -1
|
246
|
-
|
247
|
-
AxWindowsMediaPlayer2.Ctlcontrols.previous()
|
248
|
-
|
249
|
-
AxWindowsMediaPlayer2.Ctlcontrols.play()
|
250
|
-
|
251
|
-
ProgressBar1.Value = 0
|
252
|
-
|
253
|
-
Timer1.Start()
|
254
|
-
|
255
|
-
Timer2.Start()
|
256
|
-
|
257
|
-
Catch ex As Exception
|
258
|
-
|
259
|
-
MessageBox.Show("曲がありません",
|
260
|
-
|
261
|
-
"エラー",
|
262
|
-
|
263
|
-
MessageBoxButtons.OK,
|
264
|
-
|
265
|
-
MessageBoxIcon.Asterisk)
|
266
|
-
|
267
|
-
AxWindowsMediaPlayer2.Ctlcontrols.stop()
|
268
|
-
|
269
|
-
Timer1.Stop()
|
270
|
-
|
271
|
-
Timer2.Stop()
|
272
|
-
|
273
|
-
End Try
|
274
|
-
|
275
|
-
End Sub
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
Private Sub PictureBox5_Click(sender As Object, e As EventArgs) Handles PictureBox5.Click
|
280
|
-
|
281
|
-
Try
|
282
|
-
|
283
|
-
ListBox2.SelectedIndex += +1
|
284
|
-
|
285
|
-
AxWindowsMediaPlayer2.Ctlcontrols.next()
|
286
|
-
|
287
|
-
AxWindowsMediaPlayer2.Ctlcontrols.play()
|
288
|
-
|
289
|
-
ProgressBar1.Value = 0
|
290
|
-
|
291
|
-
Timer1.Start()
|
292
|
-
|
293
|
-
Timer2.Start()
|
294
|
-
|
295
|
-
Catch ex As Exception
|
296
|
-
|
297
|
-
MessageBox.Show("曲がありません",
|
298
|
-
|
299
|
-
"エラー",
|
300
|
-
|
301
|
-
MessageBoxButtons.OK,
|
302
|
-
|
303
|
-
MessageBoxIcon.Asterisk)
|
304
|
-
|
305
|
-
End Try
|
306
|
-
|
307
|
-
End Sub
|
308
|
-
|
309
|
-
Private Sub HScrollBar1_Scroll(sender As Object, e As ScrollEventArgs) Handles HScrollBar1.Scroll
|
310
|
-
|
311
|
-
AxWindowsMediaPlayer2.settings.volume = HScrollBar1.Value
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
Lb2.Text = "" & HScrollBar1.Value
|
316
|
-
|
317
|
-
End Sub
|
318
|
-
|
319
|
-
Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As System.Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer2.PlayStateChange
|
320
|
-
|
321
|
-
Try
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
For i = 0 To AxWindowsMediaPlayer2.currentPlaylist.count - 1
|
326
|
-
|
327
|
-
If AxWindowsMediaPlayer2.currentMedia.isIdentical(AxWindowsMediaPlayer2.currentPlaylist.Item(i)) Then
|
328
|
-
|
329
|
-
ListBox2.SelectedIndex = Str(i)
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
End If
|
334
|
-
|
335
|
-
Next
|
336
|
-
|
337
|
-
ProgressBar1.Value = 0
|
338
|
-
|
339
|
-
Catch ex As Exception
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
End Try
|
344
|
-
|
345
|
-
Select Case e.newState
|
346
|
-
|
347
|
-
Case WMPLib.WMPPlayState.wmppsPlaying '再生中
|
348
|
-
|
349
|
-
TextBox3.Text = AxWindowsMediaPlayer2.currentMedia.durationString
|
350
|
-
|
351
|
-
Timer3.Start()
|
352
|
-
|
353
|
-
ProgressBar1.Maximum = AxWindowsMediaPlayer2.currentMedia.duration
|
354
|
-
|
355
|
-
ProgressBar1.Value = 0
|
356
|
-
|
357
|
-
Case e.newState = WMPLib.WMPPlayState.wmppsMediaEnded '再生終了
|
358
|
-
|
359
|
-
Timer3.Stop()
|
360
|
-
|
361
|
-
ProgressBar1.Value = 0
|
362
|
-
|
363
|
-
Case WMPLib.WMPPlayState.wmppsMediaEnded
|
364
|
-
|
365
|
-
' 再生が全て終了した時()
|
366
|
-
|
367
|
-
AxWindowsMediaPlayer2.Ctlcontrols.stop()
|
368
|
-
|
369
|
-
Case Else
|
370
|
-
|
371
|
-
Debug.Print(e.newState.ToString())
|
372
|
-
|
373
|
-
End Select
|
374
|
-
|
375
|
-
End Sub
|
376
|
-
|
377
|
-
Private Sub ListBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox2.SelectedIndexChanged
|
378
|
-
|
379
|
-
If ListBox2.SelectedItem <> "" Then
|
380
|
-
|
381
|
-
AxWindowsMediaPlayer2.URL = Open00a(ListBox2.SelectedIndex)
|
382
|
-
|
383
|
-
TextBox1.Text = System.IO.Path.GetFileName(ListBox2.SelectedItem)
|
384
|
-
|
385
|
-
AxWindowsMediaPlayer2.Ctlcontrols.play()
|
386
|
-
|
387
|
-
End If
|
388
|
-
|
389
|
-
End Sub
|
390
|
-
|
391
|
-
End Class
|
392
|
-
|
393
|
-
|
11
|
+
###原因となっているコード
|
394
12
|
|
395
13
|
```
|
396
14
|
|
397
|
-
### 試したこと
|
398
|
-
|
399
|
-
listboxに入っている曲をクリックした時、選択が既に一番上になります。
|
400
|
-
|
401
|
-
曲を戻る時、2回ボタンを押すと「エラー」:曲がありません
|
402
|
-
|
403
|
-
この二つを直し方がわかりません。
|
404
|
-
|
405
|
-
###listboxの選択する時
|
406
|
-
|
407
|
-
```
|
408
|
-
|
409
|
-
Private Sub ListBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox2.SelectedIndexChanged
|
410
|
-
|
411
|
-
If ListBox2.SelectedItem <> "" Then
|
412
|
-
|
413
|
-
AxWindowsMediaPlayer2.URL = Open00a(ListBox2.SelectedIndex)
|
414
|
-
|
415
|
-
TextBox1.Text = System.IO.Path.GetFileName(ListBox2.SelectedItem)
|
416
|
-
|
417
|
-
AxWindowsMediaPlayer2.Ctlcontrols.play()
|
418
|
-
|
419
|
-
End If
|
420
|
-
|
421
|
-
End Sub
|
422
|
-
|
423
|
-
```
|
424
|
-
|
425
|
-
###曲を戻る時
|
426
|
-
|
427
|
-
```
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
15
|
+
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
432
16
|
|
433
17
|
Try
|
434
18
|
|
@@ -466,45 +50,17 @@
|
|
466
50
|
|
467
51
|
```
|
468
52
|
|
53
|
+
###試した結果
|
469
54
|
|
55
|
+
前の曲に戻ると2回押さないとメッセージボックスが出ます。
|
470
56
|
|
471
|
-
###
|
57
|
+
###教えてほしい事
|
472
58
|
|
473
|
-
|
59
|
+
1回押すだけで前の曲に戻って
|
474
60
|
|
475
|
-
|
61
|
+
メッセージボックスが出るようにするにはどうすればいいでしょうか?
|
476
62
|
|
477
|
-
Try
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
For i = 0 To AxWindowsMediaPlayer2.currentPlaylist.count - 1
|
482
|
-
|
483
|
-
If AxWindowsMediaPlayer2.currentMedia.isIdentical(AxWindowsMediaPlayer2.currentPlaylist.Item(i)) Then
|
484
|
-
|
485
|
-
ListBox2.SelectedIndex = Str(i)
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
End If
|
490
|
-
|
491
|
-
Next
|
492
|
-
|
493
|
-
ProgressBar1.Value = 0
|
494
|
-
|
495
|
-
Catch ex As Exception
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
End Try
|
500
|
-
|
501
|
-
```
|
502
|
-
|
503
|
-
for i =0 to...
|
504
|
-
|
505
|
-
これをどうしたらlistboxから曲をクリックして再生出来るようにしたいんです
|
506
|
-
|
507
|
-
教えて
|
63
|
+
教えていただけますでしょうか、お願い申し上げます。
|
508
64
|
|
509
65
|
###使ってるバージョン
|
510
66
|
|
1
音楽プレイヤーでリストボックスをクリックした時に再生出来るようにしたいです
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
音楽プレイヤーでリストボックスをクリックした時に再生出来るように
|
1
|
+
音楽プレイヤーでリストボックスをクリックした時に再生出来るように
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
### 音楽プレイヤーで
|
1
|
+
### 音楽プレイヤーでリストボックスをクリックした時に再生出来るようにしたい。
|
2
2
|
|
3
3
|
|
4
4
|
|