[WebMethod]
public void PlayAudio(int id)
{
using (The_FactoryDBContext db = new The_FactoryDBContext())
{
if (db.Words.FirstOrDefault(word => word.wordID == id).engAudio != null)
{
byte[] bytes = db.Words.FirstOrDefault(word => word.wordID == id).engAudio;
MemoryStream ms = new MemoryStream(bytes);
System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(ms);
myPlayer.Play();
}
}
}
顯然,在上面究竟播放音頻的代碼是通過System.Media.SoundPlayer對象的C#代碼,而不是瀏覽器這就是爲什麼它不會在服務器上玩。流音頻到網頁從C#
誰能告訴我如何流音頻從C#中的網頁這樣我就可以使用HTML5音頻標籤
看看這個:http://www.w3schools.com/html/html5_audio .asp,你正在執行代碼在服務器端,只需添加一個Audio標籤並將其指向您的aspx,那麼aspx應該像Taher所說的那樣返回該流。 – Gusman
請看看這個:https://developer.mozilla.org/en/docs/Web/HTML/Element/audio – rlemon