[C#] 纯文本查看 复制代码
///<summary
/// 播放声音文件
/// </summary>
/// <paramname="FileName">文件全名</param>
public voidPlaySound(string FileName)
{//要加载COM组件:Microsoft speech object Library
if (!System.IO.File.Exists(FileName))
{
return;
}
SpeechLib.SpVoiceClass pp = new SpeechLib.SpVoiceClass();
SpeechLib.SpFileStreamClass spFs = new SpeechLib.SpFileStreamClass();
spFs.Open(FileName, SpeechLib.SpeechStreamFileMode.SSFMOpenForRead,true);
SpeechLib.ISpeechBaseStream Istream = spFs as SpeechLib.ISpeechBaseStream;
pp.SpeakStream(Istream, SpeechLib.SpeechVoiceSpeakFlags.SVSFIsFilename);
spFs.Close();
}
[C#] 纯文本查看 复制代码
private voidmenuItem1_Click(object sender, System.EventArgs e)
{
OpenFileDialogofDialog = new OpenFileDialog();
ofDialog.AddExtension= true;
ofDialog.CheckFileExists= true;
ofDialog.CheckPathExists= true;
//the nextsentence must be in single line
ofDialog.Filter= "VCD文件(*.dat)|*.dat|Audio文件(*.avi)|*.avi
|WAV文件(*.wav)|*.wav|MP3文件(*.mp3)|*.mp3|所有文件 (*.*)|*.*";
ofDialog.DefaultExt= "*.mp3";
if(ofDialog.ShowDialog()== DialogResult.OK)
{
// 2003一下版本 方法this.axMediaPlayer1.FileName = ofDialog.FileName;
this.axMediaPlayer1.URL=ofDialog.FileName;//2005用法
}
}