In diesem extra meiner Visual Basic Tutorialreihe zeige ich euch, wie ihr ein Mikrophon mit mciSendStrind aufnehmt.
Quellcode:
Public Class Form1
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal Command As String, ByVal ReturnString As String, ByVal ReturnLenght As Integer, ByVal Callback As Integer) As Integer
Dim Path As String = "C:\Users\Manuel\Desktop\Test.wav"
Dim rs As String
Dim cb As String
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If Button1.Text = "Record" Then
Button1.Text = "Stop"
Button2.Enabled = False
rs = New String(" ", 128)
mciSendString("Open New Type waveaudio Alias aufnahme", rs, 128, cb)
mciSendString("record aufnahme", rs, 128, cb)
Else
Button1.Text = "Record"
Button2.Enabled = True
mciSendString("Stop aufnahme", rs, 128, cb)
mciSendString("save aufnahme " & Path, rs, 128, cb)
mciSendString("Close aufnahme", rs, 128, cb)
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
My.Computer.Audio.Play(Path, AudioPlayMode.Background)
End Sub
End Class
Keine Kommentare:
Kommentar veröffentlichen