RE: Datagrid Hyperlink field to play file system wave file help.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Steven
Thanks for your reply. Your advice and links you sent were very helpfull.

I implemented your solution using the MediaOutput.aspx page. And that
works. Thanks

However if the MsgFile field, which is passed in MediaOutput.aspx?fn={0},
has a full path e.g. c:\FP\audio\1.wav then the Hyperlink is not active. It
appears that the ':' is not allowed in the {0} value. If it contains a
partial path without the c: part (specifically the ':') it works.
What is wrong with ':' in the QueryString parameter?

Thanks
Morris


"Steven Cheng[MSFT]" wrote:

Hi Morris,

From your description, I understand your web application will display some
links on one page (through grid) and the link will point to some wav sound
so that the user can play it when click on the link. The problem is that
the wav files is in a non-virtual directory(accessible through http
address) on the server, correct?

As for this problem, I think it is doable and have several means. I'd like
to confirm following things first:

1. Are you developing through ASP.NET 1.1/VS 2003 or ASP.NET 2.0/VS 2005?

2. As for the media file(wav), how do you want to play it to client user,
among the following options:

** let the client user directly link to the media and the browser will
choose a player on the client to play it.

** embed some activex or sound tag in web page and use let the browser to
play it, thus , the client will not launch a separate player when user
click the link.


As for the wav file linking problem, I don't think we can directly use the
physical path(like c:\media\.....) because this path is not recommend for
internet application. also, the "c:\media\" physical path is only valid to
the server machine, since the page is finally displayed in client browser,
the browser will try locating the file on the client machine's disk and
won't be able to get the file.


To resolve this, I suggest you consider the following means:

1)Create an ASP.NET web page or HttpHandler which will programmtically read
the file from the non-web folder and then write it out as response stream.
e.g.

suppose the page's name is "MediaOutput.aspx", we add the following code in
its code behind:

==================
public partial class MediaOutput : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string fn = Request.QueryString["fn"];

if (string.IsNullOrEmpty(fn))
{
throw new Exception("Invalid Argument...........");
}

Response.ClearHeaders();
Response.ClearContent();

Response.ContentType = "audio/wav";

Response.WriteFile(@"D:\temp\media\" + fn);

Response.End();

}
}

============================


Then, in other page which want to reference a certain wav file in the
"D:\temp\media" folder, we no longer need to care about the physical path,
but simply use the "MediaOutput.aspx" to get the wav stream. e.g.


<a href="MediaOutput.aspx?fn=ding.wav" >play ding.wav </>


if you want to create a custom httphandler to do the work, please refer to
the following article:

http://weblogs.asp.net/cazzu/archive/2003/08/27/25568.aspx




However, as I've mentioned, if you directly point to the wav stream in the
hyperlink, the wav will be played in a new player window at
client-side(maybe media player or other player...). If you do not want to
let a new launched player to do it, you can have a look at the following
web pages:

#Playing Sounds On The Web
http://www.w3schools.com/media/media_browsersounds.asp

#Demonstration of Different Ways to Play a Sound from a Web Page
http://www.phon.ucl.ac.uk/home/mark/audio/play.htm


it demonstrate several means to play sound, you can even use javascript to
make a certain element(like <bgsound> or <embed> to reference the media
stream output by the "mediaoutput.aspx" page above).

Hope this helps. If there is anything unclear, please feel free to let me
know.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.



.



Relevant Pages

  • RE: Datagrid Hyperlink field to play file system wave file help.
    ... links on one page and the link will point to some wav sound ... As for the media file, how do you want to play it to client user, ...
    (microsoft.public.dotnet.framework.aspnet)
  • high noise/signal in a simple serial to mono dac module
    ... I used the following synthesis to play the sound data delivered through the serial interface. ... Another problem I have with simple WAV file is I don't know how to extract volume information. ... async_transmitter #) serializer( ...
    (comp.arch.fpga)
  • Re: Play .wav music file
    ... I have a program to play a .wav music. ... When I play it using Real Player, ... The .WAV file format is a container format. ... Sun's basic implementation only allows for playback of PCM encoded WAV files, though you can add plugins to add support to other encoding systems. ...
    (comp.lang.java.programmer)
  • Re: DoEvents?
    ... that if you call the snd api to play another wav file ... short wav sound probaably a ding or something......on the command button ... > need to play it asynchronously. ...
    (microsoft.public.vb.enterprise)
  • Re: Media Player 10 mobile doesnt play wav file
    ... setting of the program and associate the .wav file with the program. ... It noweil Smith [MVP Digital Media]" ... try and play the voicemail attachment. ...
    (microsoft.public.pocketpc.multimedia)