반응형
*VBNET API 를 이용한 Wav 파일 재생 예제...
- 사용한 컨트롤 : Button 3개, Label 1개
전체 소스 코드
Form1.vb
Imports System.Runtime.InteropServices
Imports System.Text
Public Class Form1
<DllImport("winmm.dll")> _
Private Shared Function mciSendString(ByVal command As String, ByVal buffer As StringBuilder, ByVal bufferSize As Integer, ByVal hwndCallback As IntPtr) As Integer
End Function
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
'File Open
Dim ofd As OpenFileDialog = New OpenFileDialog
ofd.Filter = "WAV File(*.wav) | *.wav"
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
label1.Text = ofd.FileName
End If
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
'Play
If Not System.IO.File.Exists(label1.Text) Then
Return
End If
mciSendString("open """ + label1.Text + """ type mpegvideo alias MediaFile", Nothing, 0, IntPtr.Zero)
mciSendString("play MediaFile", Nothing, 0, IntPtr.Zero)
End Sub
Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click
'Stop
mciSendString("Close MediaFile", Nothing, 0, IntPtr.Zero)
End Sub
End Class
*예제 결과
https://kdsoft-zeros.tistory.com/192
반응형
'VB.NET Programming' 카테고리의 다른 글
[VBNET] [API] Form - Animate (0) | 2020.04.24 |
---|---|
[VBNET] PC 사용 시간 얻어 오기 (PC Use Time) (0) | 2020.04.23 |
[VBNET] SendKeys - 화면 캡쳐 (Screen Capture) (0) | 2020.04.16 |
[VBNET] 선택된 프로세스 죽이기 (Kill Process) (0) | 2020.04.14 |
[VBNET] 화면 캡쳐 (Screen Capture) (0) | 2020.04.10 |