This is a simple voice recording project developed in VB.NET. It records the sound and then save the output file (.MP3) in local disk and then we can also play the recorded file through this project. mciSendString function is used in this project so you will also learn about mciSendString function. in this blog post.
Public Class Form1 Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer Private Sub btnRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRecord.Click btnRecord.Enabled = False btnStop.Enabled = True mciSendString("open new Type waveaudio Alias hrsSound", "", 9, 9) mciSendString("record hrsSound", "", 9, 9) Label1.Text = "Recording..." Label1.Visible = True End Sub Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click btnRecord.Enabled = True btnStop.Enabled = False btnPlay.Enabled = True mciSendString("save hrsSound d:\mySound.mp3", "", 9, 9) mciSendString("close hrsSound", "", 0, 0) MsgBox("File Created: d:\mySound.mp3") Label1.Text = "Stopped..." Label1.Visible = False End Sub Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlay.Click Label1.Text = "Playing..." Label1.Visible = True My.Computer.Audio.Play("d:\mySound.mp3", AudioPlayMode.Background) End Sub End Class
DOWNLOAD FULL PROJECT (ZIP FILE)
mciSendString function sends a command string to an MCI device. The device that the command is sent to is specified in the command string.
Syntax :
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
ByVal lpstrCommand As String, _ ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, _
ByVal hwndCallback As Long _
) As Long
Library :
winmm.dll
Parameters :
· lpszCommand
Address of a null-terminated string that specifies an MCI command string. For more information about the command strings, visit HERE
· lpszReturnString
Address of a buffer that receives return information. If no return information is needed, this parameter can be NULL.
· cchReturn
Size, in characters, of the return buffer specified by the lpszReturnString parameter.
· hwndCallback
Handle of a callback window if the notify flag was specified in the command string.
Source References - 1 , 2
If you have any query to ask or any idea to share then please comment below.
कोडर्स के लिए दृश्य मूल कार्यक्रम
ReplyDeleteएक नई निर्देशिका दृश्य मूल कोड बनाएँ
wow this saintly however ,I love your enter plus nice pics might be part personss negative love being defrent mind total poeple , https://www.pageview.com/ This is important, though it's necessary to help you head over to it weblink:
ReplyDelete