Vb.Net programlama dili kullanilarak, bilgisayarimiz üzerinden ses kayit islemi gerçeklestirmek istedigimizde projemize System.Runtime.InteropServices sinifimiza import ederek, ses kayit islemlerimizi gerçeklestiriyoruz.
Kodlarimizi inceleyecek olursak eger;
Imports System.IO
Imports System.Runtime.InteropServices
Public Class Form1
Private Shared Function mciSendString(ByVal command As String, ByVal buffer As String, ByVal bufferSize As Integer, ByVal hwndCallback As IntPtr) As Integer
End Function
Dim kayityolu As String = Directory.GetCurrentDirectory() & "\" & "SesKayit" & "\" + "Kayit.wav"
Dim recording As Boolean = False
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
btnplay.Enabled = False
Label1.Text = "Kayit baslatilmadi !"
End Sub
Private Sub btnrecord_Click(sender As Object, e As EventArgs) Handles btnrecord.Click
If recording = False Then
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0)
mciSendString("record recsound", "", 0, 0)
recording = True
btnrecord.Text = "Durdur"
Label1.Text = "Ses kaydi baslatildi !"
Else
mciSendString("save recsound " & kayityolu, "", 0, 0)
mciSendString("close recsound ", "", 0, 0)
btnplay.Enabled = True
recording = False
btnrecord.Text = "Baslat"
Label1.Text = "Ses kaydi durduruldu !"
End If
End Sub
Private Sub btnplay_Click(sender As Object, e As EventArgs) Handles btnplay.Click
My.Computer.Audio.Play(kayityolu)
End Sub
End Class
Uygulama dosyasini buradan indirebilirsiniz !