資源簡(jiǎn)介
采集麥克風(fēng)輸入并播放
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?Oraycn.MPlayer;
using?Oraycn.MCapture?;
namespace?Oraycn.MPlayerDemo
{
????//?更多實(shí)用組件,請(qǐng)參見?www.oraycn.com
????public?partial?class?Form1?:?Form
????{
????????private?IAudioPlayer?audioPlayer;
????????private?IMicrophoneCapturer?microphoneCapturer;
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button_mic_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????this.microphoneCapturer?=?CapturerFactory.CreateMicrophoneCapturer(int.Parse(this.textBox_mic.Text));
????????????????this.microphoneCapturer.AudioCaptured?+=?new?ESBasic.CbGeneric(microphoneCapturer_AudioCaptured);
????????????????this.audioPlayer?=?PlayerFactory.CreateAudioPlayer(int.Parse(this.textBox_speaker.Text)?16000?1?16?2);
????????????????this.microphoneCapturer.Start();
????????????????this.label_msg.Text?=?“正在采集麥克風(fēng),并播放?.?.?.“;
????????????????this.label_msg.Visible?=?true;
????????????????this.button_wav.Enabled?=?false;
????????????????this.button_mic.Enabled?=?false;
????????????????this.button_stop.Enabled?=?true;
????????????}
????????????catch?(Exception?ee)
????????????{
????????????????MessageBox.Show(ee.Message);
????????????}
????????}
????????void?microphoneCapturer_AudioCaptured(byte[]?audioData)
????????{
????????????if?(this.audioPlayer?!=?null)
????????????{
????????????????this.audioPlayer.Play(audioData);
????????????}
????????}
????????private?void?button_wav_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????string?path?=?ESBasic.Helpers.FileHelper.GetFileToOpen2(“請(qǐng)選擇要播放的wav文件“?AppDomain.CurrentDomain.baseDirectory?“.wav“);
????????????????if?(path?==?null)
????????????????{
????????????????????return;
????????????????}
????????????????AudioInformation?info?=?PlayerFactory.ParseWaveFile(path);
????????????????if?(info.FormatTag?!=?(int)WaveFormats.Pcm)
????????????????{
????????????????????MessageBox.Show(“僅僅支持PCM編碼方式的語音數(shù)據(jù)!“);
????????????????????return;
????????????????}
????????????????int?secs?=?info.GetTimeInMsecs()?/?1000;?//聲音數(shù)據(jù)的播放時(shí)長(zhǎng)
????????????????this.audioPlayer?=?PlayerFactory.CreateAudioPlayer(int.Parse(this.textBox_speaker.Text)?info.SampleRate?info.ChannelCount?info.BitsNumber?secs?+?1);
????????????????this.audioPlayer.Play(info.AudioData);
????????????????this.label_msg.Text?=?“正在播放wav文件?.?.?.“;
????????????????this.label_msg.Visible?=?true;
????????????????this.button_wav.Enabled?=?false;
????????????????this.button_mic.Enabled?=?false;
????????????????this.button_stop.Enabled?=?true;
????????????}
????????????catch?(Exception?ee)
????????????{
????????????????MessageBox.Show(ee.Message);
????????????}
????????}
????????private?void?Form1_F
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2020-07-30?17:46??Oraycn.MPla
?????目錄???????????0??2020-07-30?17:46??Oraycn.MPla
?????目錄???????????0??2020-07-30?17:46??Oraycn.MPla
?????目錄???????????0??2020-07-30?17:46??Oraycn.MPla
?????文件???????53248??2019-12-23?11:56??Oraycn.MPla
?????目錄???????????0??2020-07-30?17:46??Oraycn.MPla
?????目錄???????????0??2020-07-30?17:46??Oraycn.MPla
?????文件???????????0??2019-12-23?11:56??Oraycn.MPla
?????文件??????675840??2019-12-23?11:56??Oraycn.MPla
?????目錄???????????0??2020-07-30?17:46??Oraycn.MPla
?????文件??????442880??2019-12-20?11:21??Oraycn.MPla
?????文件??????237947??2019-12-20?11:21??Oraycn.MPla
?????文件?????1226752??2020-06-01?09:03??Oraycn.MPla
?????文件?????1028808??2019-12-20?11:31??Oraycn.MPla
?????文件?????1137664??2020-06-22?09:04??Oraycn.MPla
?????文件?????1075481??2019-12-20?11:33??Oraycn.MPla
?????文件????????6550??2015-07-08?15:46??Oraycn.MPla
?????文件????????4334??2015-07-08?15:56??Oraycn.MPla
?????文件????????5817??2015-07-08?15:46??Oraycn.MPla
?????文件????????4124??2015-11-10?15:43??Oraycn.MPla
?????文件????????1557??2015-11-10?15:43??Oraycn.MPla
?????文件???????28160??2020-09-17?14:54??Oraycn.MPla
?????文件?????????535??2015-07-08?15:56??Oraycn.MPla
?????目錄???????????0??2020-07-30?17:46??Oraycn.MPla
?????文件????????1386??2015-07-07?16:56??Oraycn.MPla
?????文件????????2876??2015-11-10?11:24??Oraycn.MPla
?????文件????????5612??2015-07-06?11:28??Oraycn.MPla
?????文件????????1118??2015-11-10?11:24??Oraycn.MPla
?????文件?????????249??2015-07-06?11:28??Oraycn.MPla
?????文件?????????144??2015-11-10?11:24??Oraycn.MPla
?????目錄???????????0??2020-07-30?17:46??Oraycn.MPla
............此處省略41個(gè)文件信息
- 上一篇:C#教程(非常基礎(chǔ))
- 下一篇:C#獲取U盤信息
評(píng)論
共有 條評(píng)論