Windows Mobile audio input

Source: Internet
Author: User
Using System;
Using System. Collections. Generic;
Using System. text;
Using Opennetcf. Media. waveaudio;
Using System. IO;

Namespace Record
{
Class Tools
{
Private   Static Stream recordstream;
Private   Static Recorder =   New Recorder ();
Private   Static Player player =   New Player ();

Public   Static   Void Recordstart (string recordfile)
{
Recordstream = File. openwrite (recordfile );
Recorder. recordfor (recordstream, 60   *   10 , Soundformats. mono8bit11khz );
// Recorder. recordfor (recordstream 1000 );
}

Public   Static   Void Recordstop ()
{
While (recorder. recording)
{< br> recorder. stop ();
system. windows. forms. application. doevents ();
}< BR >}

Public static void play (string recordfile)
{< br> stream = file. openread (recordfile);
player. play (Stream);
}

Public static string createrecordfile ()
{< br> return datetime. now. tostring ( " yyyymmddhhmmss " ) + " . wav " ;
}

Public   Static String getcurpath ()
{
Return System. Io. Path. getdirectoryname (system. reflection. Assembly. getexecutingassembly (). getname (). codebase );
}
}
}
Using System;
Using System. Collections. Generic;
Using System. componentmodel;
Using System. Data;
Using System. drawing;
Using System. text;
Using System. Windows. forms;
Using System. IO;

Namespace Record
{
Public   Partial   Class Form1: Form
{
String recordfile =   "" ;
Public Form1 ()
{
Initializecomponent ();
}

Private VoidForm1_load (ObjectSender, eventargs E)
{

}

Private   Void Button#click ( Object Sender, eventargs E)
{
Recordfile = Tools. getcurpath () +   " \\ "   + Tools. createrecordfile ();
Tools. recordstart (recordfile );
}

Private VoidButton2_click (ObjectSender, eventargs E)
{
Tools. recordstop ();
}

Private   Void Button3_click ( Object Sender, eventargs E)
{
If (File. exists (recordfile ))
{
Tools. Play (recordfile );
}
Else
{
MessageBox. Show ( " The audio file does not exist! " );
}
}

Private VoidMenuitem1_click (ObjectSender, eventargs E)
{

}

Private VoidMenuitem2_click (ObjectSender, eventargs E)
{
Application. Exit ();
}
}
}

/Files/tt_mc/record.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.