Advertisement
calfred2808

Record Play Audio

Dec 4th, 2016
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.39 KB | None | 0 0
  1. Public Class Form1
  2.  
  3.     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
  4.  
  5.     Private Sub btnRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRecord.Click
  6.  
  7.         btnRecord.Enabled = False
  8.  
  9.         btnStop.Enabled = True
  10.  
  11.         mciSendString("open new Type waveaudio Alias hrsSound", "", 9, 9)
  12.  
  13.         mciSendString("record hrsSound", "", 9, 9)
  14.  
  15.         Label1.Text = "Recording..."
  16.  
  17.         Label1.Visible = True
  18.  
  19.     End Sub
  20.  
  21.     Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
  22.  
  23.         btnRecord.Enabled = True
  24.  
  25.         btnStop.Enabled = False
  26.  
  27.         btnPlay.Enabled = True
  28.  
  29.         mciSendString("save hrsSound d:\mySound.mp3", "", 9, 9)
  30.  
  31.         mciSendString("close hrsSound", "", 0, 0)
  32.  
  33.         MsgBox("File Created: d:\mySound.mp3")
  34.  
  35.         Label1.Text = "Stopped..."
  36.  
  37.         Label1.Visible = False
  38.  
  39.     End Sub
  40.  
  41.     Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlay.Click
  42.  
  43.         Label1.Text = "Playing..."
  44.  
  45.         Label1.Visible = True
  46.  
  47.         My.Computer.Audio.Play("d:\mySound.mp3", AudioPlayMode.Background)
  48.  
  49.     End Sub
  50. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement