using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using System.Runtime.InteropServices;
using System.Speech.Synthesis;
using System.Text;
namespace QuickEAS.CoreLib
{
public class LibSoundPlayer
{
public static void PlayWav(string fileName)
{
SoundPlayer player = new SoundPlayer();
player.SoundLocation = fileName;
player.Load(); //同步加載聲音
player.Play(); //啓用新線程播放
//player.PlayLooping(); //循環播放模式
//player.PlaySync(); //UI線程同步播放
}
/// <summary>朗讀播放文本</summary>
/// <param name="text"></param>
public static void PlayText(string text)
{
SpeechSynthesizer synth = new SpeechSynthesizer();
synth.SpeakAsync(text);
}
}
}
【代碼片段】播放聲音
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.