locked
Recording voice using winmm.dll RRS feed

  • Question

  • User2130252872 posted

    Hi,

    I have a created a small application that records and save audio. However, my application needs to save the wave file to the sever computer. 

    I used my code in my asp.net application ,It is working fine in local machine.

    But if I publish it on server, It does not save the recording on server machine. But it create wav file with zero length.

    Please can some one help me with this problem??

    I am using VS2017 Web form application.

    My code : 

    public class AudioHandler 
        {

            [DllImport("winmm.dll", CharSet = CharSet.Auto)]
            private static extern uint mciSendString([MarshalAs(UnmanagedType.LPTStr)] string command,
                                                    StringBuilder returnValue,
                                                    int returnLength,
                                                    IntPtr winHandle);

            public AudioHandler()
            {
                mciSendString("Open new Type waveaudio alias rec", null, 0, IntPtr.Zero);
            }
            public void Record()
            {
                mciSendString("Record rec", null, 0, IntPtr.Zero);
            }

            public void Save(string path)
            {
                uint result = 0;
                result = mciSendString("save rec "+ path , null, 0, IntPtr.Zero);
              
            }

            public void Dispose()
            {
                mciSendString("close rec", null, 0, IntPtr.Zero);
            }
        }

    NOTE :  

    My problem is every thing was working fine, audio file also creating but content is missing. 

    http://www.dotnetspider.com/resources/4967-How-record-voice-from-microphone.aspx

    Same issue 

    Thursday, May 23, 2019 4:06 AM

Answers

  • User-821857111 posted

    HI 

    But it totally working fine on local. That is why I am wondering.  

    Yes, because your development machine acts as the server as well as the client. So your ASP.NET application behaves like a Windows application. Once your application is deployed to a web server, it can only use winmm.dll to process audio that comes in via the server's microphone. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 24, 2019 6:02 PM

All replies

  • User-821857111 posted

    When you run the app on your machine, it acts as both client and server. However, when you deploy it to a server, the server-side application has no access to the microphone on a client machine. You should look at client side APIs that enable recording. Do a Google search for "record microphone javascript" for some articles and ideas.

    Thursday, May 23, 2019 8:02 AM
  • User-1038772411 posted

    Hi, Yasinthas3@gmail.com

    I am giving You One Reference project below that provide completely code as you want. kindly please implement wisely it will work for you fine.

    https://www.c-sharpcorner.com/article/an-audio-recorder-using-winmm-dll/

    Thanks.

    Thursday, May 23, 2019 10:50 AM
  • User-821857111 posted

    kindly please implement wisely it will work for you fine.

    https://www.c-sharpcorner.com/article/an-audio-recorder-using-winmm-dll/

    It won't work fine at all. You can't use winmm.dll in a web application. 

    Thursday, May 23, 2019 11:11 AM
  • User2130252872 posted

    HI 

    But it totally working fine on local. That is why I am wondering.  

    Friday, May 24, 2019 5:25 AM
  • User-2015242085 posted

    Hi

    You can use the web audio api to record audio from a web page

    https://online-voice-recorder.com/es/

    Friday, May 24, 2019 4:56 PM
  • User-821857111 posted

    HI 

    But it totally working fine on local. That is why I am wondering.  

    Yes, because your development machine acts as the server as well as the client. So your ASP.NET application behaves like a Windows application. Once your application is deployed to a web server, it can only use winmm.dll to process audio that comes in via the server's microphone. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 24, 2019 6:02 PM
  • User2130252872 posted

    Hi Mikesdotnett...,

    Since this is a "winmm.dll" issue, I change my code to JavaScript. I used "MediaStreamRecorder.js" But once I published in to the sever , recording was not working. Do you have any idea? or any way to record voice from client and save it to sever.

    Thank You

    Monday, May 27, 2019 5:15 AM
  • User-821857111 posted

    Do you have any idea?
    No. You should post a separate question about third party JS libraries in the Component Discussions or HTML, CSS and Javascript forums

    Monday, May 27, 2019 7:31 PM