asp.net SoundPlayer not playing from server

↘锁芯ラ 提交于 2019-12-12 00:50:16

问题


I have made the simplest test in order to check if SoundPlayer will play a wave file. From the local machine works just fine, once the site is on IIS it doesn't play the sounds (or give any error).

Here is the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Media;

public partial class Default2 : System.Web.UI.Page
{   public SoundPlayer spWave;
    protected void Page_Load(object sender, EventArgs e)
    {

        spWave = new SoundPlayer("\\\\server\\site\\wavetest.wav");
        spWave.Play();
    }
}

Is there anything else I need to add to the .aspx file to get this to work?

Or is there an easier way of playing very short wave files, without displaying any media controls on the page?


回答1:


SoundPlayer is not an aspx control, you should find a web control which can play your wav file and put that on your aspx page. Now you play the wav on your web server in iis every time your page loads.

You can start here looking for playing wav files on a webpage: google: wav aspx



来源:https://stackoverflow.com/questions/15613049/asp-net-soundplayer-not-playing-from-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!