By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,480 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,480 IT Pros & Developers. It's quick & easy.

audio recording problem with mciExecute() in vb.net

P: 17
I am developing a web application in that I need to record audio, for that I am importing "winmm.dll" and

using mciExecute function.(the following code is vb.net). If I have posted in irrelavent forum please let me

know where should I post questions related to audio and video (for web development).
Expand|Select|Wrap|Line Numbers
  1. Imports System.Runtime.InteropServices
  2. Imports Microsoft.VisualBasic
  3. Imports Microsoft.VisualBasic.Devices
  4.  
  5. Partial Class audioRec
  6.     Inherits System.Web.UI.Page
  7.     <DllImport("winmm.dll", EntryPoint:="mciExecute", CharSet:=CharSet.Ansi, SetLastError:=True, 
  8.  
  9. ExactSpelling:=True)> Private Shared Function mciExecute(ByVal lpstrCommand As String) As Boolean
  10.     End Function
  11.  
  12.     Protected Sub BtnStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnStart.Click
  13.  
  14.         mciExecute("open new Type waveaudio Alias recsound1")
  15.         mciExecute("set recsound1 time format ms bitspersample 16 channels 1 samplespersec 11025")
  16.         mciExecute("record recsound1")
  17.  
  18.  
  19.  
  20.     End Sub
  21.  
  22.     Protected Sub BtnStop_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnStop.Click
  23.         mciExecute("save recsound1 c:\\record.wav")
  24.         mciExecute("close recsound1 ")
  25.  
  26.         Dim c As New Computer
  27.         c.Audio.Stop()
  28.     End Sub
  29.  
  30.     Protected Sub BTNplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTNplay.Click
  31.         Dim computer As New Computer
  32.         computer.Audio.Play("c:\\record.wav", AudioPlayMode.Background)
  33.     End Sub
  34. End Class
  35.  
but when I am clicking the start button "the order in which you are passing parameters is invalid please

correct the order" msg is getting displayed. I need to to record an audio file in "8khz, 16 bit, mono"

format. How can I meet this requirement.

i will be thankful for ur suggestions..

with regards,
kiran
Oct 26 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.