Microsoft.VisualBasic missing namespace
-
Dear All I've been trying to code a code that record the users' voice from the mic but I seem to get stuck in some portion in which it keep showing me the error that the Microsoft.visualbasic.devices is missing? any help here is my code incase the problem is on my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic.Devices; //My problem is here
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;namespace WindowsApplication1
{public partial class Form1 : Form { \[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)\] private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback); public Form1() { InitializeComponent(); } private void Form1\_Load(object sender, EventArgs e) { } private void Record\_Click(object sender, EventArgs e) { // record from microphone mciSendString("open new Type waveaudio Alias recsound", "", 0, 0); mciSendString("record recsound", "", 0, 0); } private void SaveStop\_Click(object sender, EventArgs e) { // stop and save mciSendString("save recsound c:\\\\record.wav", "", 0, 0); mciSendString("close recsound ", "", 0, 0); Computer c = new Computer(); c.Audio.Stop(); } private void Read\_Click(object sender, EventArgs e) { Computer computer = new Computer(); computer.Audio.Play("c:\\\\record.wav", AudioPlayMode.Background); } }
}
-
Dear All I've been trying to code a code that record the users' voice from the mic but I seem to get stuck in some portion in which it keep showing me the error that the Microsoft.visualbasic.devices is missing? any help here is my code incase the problem is on my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic.Devices; //My problem is here
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;namespace WindowsApplication1
{public partial class Form1 : Form { \[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)\] private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback); public Form1() { InitializeComponent(); } private void Form1\_Load(object sender, EventArgs e) { } private void Record\_Click(object sender, EventArgs e) { // record from microphone mciSendString("open new Type waveaudio Alias recsound", "", 0, 0); mciSendString("record recsound", "", 0, 0); } private void SaveStop\_Click(object sender, EventArgs e) { // stop and save mciSendString("save recsound c:\\\\record.wav", "", 0, 0); mciSendString("close recsound ", "", 0, 0); Computer c = new Computer(); c.Audio.Stop(); } private void Read\_Click(object sender, EventArgs e) { Computer computer = new Computer(); computer.Audio.Play("c:\\\\record.wav", AudioPlayMode.Background); } }
}
-
Dear All I've been trying to code a code that record the users' voice from the mic but I seem to get stuck in some portion in which it keep showing me the error that the Microsoft.visualbasic.devices is missing? any help here is my code incase the problem is on my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic.Devices; //My problem is here
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;namespace WindowsApplication1
{public partial class Form1 : Form { \[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)\] private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback); public Form1() { InitializeComponent(); } private void Form1\_Load(object sender, EventArgs e) { } private void Record\_Click(object sender, EventArgs e) { // record from microphone mciSendString("open new Type waveaudio Alias recsound", "", 0, 0); mciSendString("record recsound", "", 0, 0); } private void SaveStop\_Click(object sender, EventArgs e) { // stop and save mciSendString("save recsound c:\\\\record.wav", "", 0, 0); mciSendString("close recsound ", "", 0, 0); Computer c = new Computer(); c.Audio.Stop(); } private void Read\_Click(object sender, EventArgs e) { Computer computer = new Computer(); computer.Audio.Play("c:\\\\record.wav", AudioPlayMode.Background); } }
}
Project-Add Reference- in the .Net Option Find Micorsoft.VisualBasic and Add it to the Reference you will find you can using the namespace now;
-
The SoundPlayer class is new to the .net framework, version 2.0. It provides the StartAsync and Stop methods. Put it as a variable in the SaveStop_Click and the Read_Click voids, and instantiate it. Then, just call the methods. Overall, it would look like this:
private void SaveStop_Click(object sender, EventArgs e)
{
//Your mciSendString stuff goes here
SoundPlayer player = new SoundPlayer();player.Stop();
}
private void Read_Click(object sender, EventArgs e)
{
SoundPlayer player = new SoundPlayer(@"C:\record.wav");player.PlayAsync();
}