Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to Save the voice record file in the client system Using MCI in c# .net 2.0 web application

How to Save the voice record file in the client system Using MCI in c# .net 2.0 web application

Scheduled Pinned Locked Moved ASP.NET
csharpdesignsysadminsecuritytutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bruze
    wrote on last edited by
    #1

    c# .net 2.0 web application. I have tried following code.It is working fine in Server box (I have created vitrual direcory for record folder in c: drive "), but it not working in client box.

    c:\\record\\record.wav"

    Code

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Microsoft.VisualBasic.Devices;
    using Microsoft.VisualBasic;
    using System.Runtime.InteropServices;

    public partial class Recording : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    
    \[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);
    
    
    protected void btnRecord\_Click(object sender, EventArgs e)
    {
        //Record
        mciSendString("open new Type waveaudio Alias recsound", "", 0, 0); 
        mciSendString("record recsound", "", 0, 0);
    }
    
    protected void btnSaveStop\_Click(object sender, EventArgs e)
    {
        // stop and save
        mciSendString("save recsound c:\\\\record\\\\record.wav", "", 0, 0); 
        mciSendString("close recsound ", "", 0, 0); 
        Computer c = new Computer(); c.Audio.Stop();
    
    
    }
    
    protected void btnRead\_Click(object sender, EventArgs e)
    {
        //Read
        Computer computer = new Computer();
        computer.Audio.Play("c:\\\\record\\\\record.wav", AudioPlayMode.Background);
    }
    

    }

    Thanks, Bruze

    A R 2 Replies Last reply
    0
    • B bruze

      c# .net 2.0 web application. I have tried following code.It is working fine in Server box (I have created vitrual direcory for record folder in c: drive "), but it not working in client box.

      c:\\record\\record.wav"

      Code

      using System;
      using System.Data;
      using System.Configuration;
      using System.Collections;
      using System.Web;
      using System.Web.Security;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using System.Web.UI.HtmlControls;
      using Microsoft.VisualBasic.Devices;
      using Microsoft.VisualBasic;
      using System.Runtime.InteropServices;

      public partial class Recording : System.Web.UI.Page
      {
      protected void Page_Load(object sender, EventArgs e)
      {

      }
      
      \[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);
      
      
      protected void btnRecord\_Click(object sender, EventArgs e)
      {
          //Record
          mciSendString("open new Type waveaudio Alias recsound", "", 0, 0); 
          mciSendString("record recsound", "", 0, 0);
      }
      
      protected void btnSaveStop\_Click(object sender, EventArgs e)
      {
          // stop and save
          mciSendString("save recsound c:\\\\record\\\\record.wav", "", 0, 0); 
          mciSendString("close recsound ", "", 0, 0); 
          Computer c = new Computer(); c.Audio.Stop();
      
      
      }
      
      protected void btnRead\_Click(object sender, EventArgs e)
      {
          //Read
          Computer computer = new Computer();
          computer.Audio.Play("c:\\\\record\\\\record.wav", AudioPlayMode.Background);
      }
      

      }

      Thanks, Bruze

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      This is the basics of ASP.NET. If you play audio using Computer.Audio.Play it will always run in the server. What you have to do is to download the wav file to the client and then invoke the browser media object installed to run your wav file. For simplicity you can also use

      Body BgSound ="~/record.wav"

      I recommend to read basic books before you do programming in Web Environment, as there is some problems in the basics of this environment. Hope you understand. :cool: Also on your problem if you are using BgSound or anything, always refer to the Virtual path, as Physical path of your server is different from the clients. ;)

      Abhishek Sur


      My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

      **Don't forget to click "Good Answer" if you like to.

      B 1 Reply Last reply
      0
      • A Abhishek Sur

        This is the basics of ASP.NET. If you play audio using Computer.Audio.Play it will always run in the server. What you have to do is to download the wav file to the client and then invoke the browser media object installed to run your wav file. For simplicity you can also use

        Body BgSound ="~/record.wav"

        I recommend to read basic books before you do programming in Web Environment, as there is some problems in the basics of this environment. Hope you understand. :cool: Also on your problem if you are using BgSound or anything, always refer to the Virtual path, as Physical path of your server is different from the clients. ;)

        Abhishek Sur


        My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

        **Don't forget to click "Good Answer" if you like to.

        B Offline
        B Offline
        bruze
        wrote on last edited by
        #3

        Thanks For Your Reply. Actually, First of all I want to record the audio and Save into Client box using browser.Once I recorded the audio file then Upload into Server folder. Thanks, Bruze

        modified on Monday, September 21, 2009 5:29 PM

        A 1 Reply Last reply
        0
        • B bruze

          Thanks For Your Reply. Actually, First of all I want to record the audio and Save into Client box using browser.Once I recorded the audio file then Upload into Server folder. Thanks, Bruze

          modified on Monday, September 21, 2009 5:29 PM

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          Yes. Say you upload a file into the server say abc.wav save this file into a directory which is within the virtual path. say c:\mywebsite\xyz folder. so that you can call http://yourserver.com/xyz/abc.wav Now create your webpage such that it plays audio using this path.. not your original physical path. Finally take any of the different steps mentioned here to play your sound in the browser: http://www.phon.ucl.ac.uk/home/mark/audio/play.htm[^] Hope you understand this. :)

          Abhishek Sur


          My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

          **Don't forget to click "Good Answer" if you like to.

          B 1 Reply Last reply
          0
          • A Abhishek Sur

            Yes. Say you upload a file into the server say abc.wav save this file into a directory which is within the virtual path. say c:\mywebsite\xyz folder. so that you can call http://yourserver.com/xyz/abc.wav Now create your webpage such that it plays audio using this path.. not your original physical path. Finally take any of the different steps mentioned here to play your sound in the browser: http://www.phon.ucl.ac.uk/home/mark/audio/play.htm[^] Hope you understand this. :)

            Abhishek Sur


            My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

            **Don't forget to click "Good Answer" if you like to.

            B Offline
            B Offline
            bruze
            wrote on last edited by
            #5

            I got it. Thank you So much for your reply

            1 Reply Last reply
            0
            • B bruze

              c# .net 2.0 web application. I have tried following code.It is working fine in Server box (I have created vitrual direcory for record folder in c: drive "), but it not working in client box.

              c:\\record\\record.wav"

              Code

              using System;
              using System.Data;
              using System.Configuration;
              using System.Collections;
              using System.Web;
              using System.Web.Security;
              using System.Web.UI;
              using System.Web.UI.WebControls;
              using System.Web.UI.WebControls.WebParts;
              using System.Web.UI.HtmlControls;
              using Microsoft.VisualBasic.Devices;
              using Microsoft.VisualBasic;
              using System.Runtime.InteropServices;

              public partial class Recording : System.Web.UI.Page
              {
              protected void Page_Load(object sender, EventArgs e)
              {

              }
              
              \[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);
              
              
              protected void btnRecord\_Click(object sender, EventArgs e)
              {
                  //Record
                  mciSendString("open new Type waveaudio Alias recsound", "", 0, 0); 
                  mciSendString("record recsound", "", 0, 0);
              }
              
              protected void btnSaveStop\_Click(object sender, EventArgs e)
              {
                  // stop and save
                  mciSendString("save recsound c:\\\\record\\\\record.wav", "", 0, 0); 
                  mciSendString("close recsound ", "", 0, 0); 
                  Computer c = new Computer(); c.Audio.Stop();
              
              
              }
              
              protected void btnRead\_Click(object sender, EventArgs e)
              {
                  //Read
                  Computer computer = new Computer();
                  computer.Audio.Play("c:\\\\record\\\\record.wav", AudioPlayMode.Background);
              }
              

              }

              Thanks, Bruze

              R Offline
              R Offline
              rahul1455
              wrote on last edited by
              #6

              hi through this code i am recording audios and listening locally but I am unable to record audios on online(production server).its showing empty file.recording not happening there. Please suggest me my code as follows protected void btnSaveStop_Click(object sender, EventArgs e) { shortPath = Server.MapPath("~/Audios/" + txtTag.Text + ".wav"); formatShortPath = string.Format("save recsound \"{0}\"", shortPath); mciSendString(string.Format("{0}", formatShortPath), null, 0, 0); mciSendString("save recsound ", "", 0, 0); mciSendString("close recsound ", "", 0, 0); Computer c = new Computer(); c.Audio.Stop(); }

              modified on Friday, March 12, 2010 1:08 AM

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups