Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
596 views
in Technique[技术] by (71.8m points)

c# - asp.net SoundPlayer not playing from server

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...