Vista problem with playing .wav files from C#

R

rnmalhotra

Experts,

I have a simple .aspx page that takes a path to a .wav file, and
plays it. This page works fine on all OSs (Windows 2000, Windows
2003,
Windows XP), but not on Vista. Could the protected mode on vista be
interfering with this page? Any other ideas on why the code does not
work on Vista would be greatly appreciated.

I acces thie page as http://localhost/WavFileTest.aspx, and enter "C:
\test.wav" as the path.

The (simple) code for this page is


==========WavTestFile.aspx
page========================================
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="WavFileTest.aspx.cs" Inherits="MiscTests.WavFileTest" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Enter File Location: <asp:TextBox ID="WavFileName"
runat="server" />
<asp:Button ID="Play" Text="Play" runat="server"
OnClick="Play_Clicked" />
</div>
</form>
</body>
</html>


==============WavTestFile.aspx.cs code behind ==

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Media;


namespace MiscTests
{
public partial class WavFileTest : System.Web.UI.Page
{
protected TextBox WavFileName;
protected Button Play;
protected void Page_Load(object sender, EventArgs e)
{


}
protected void Play_Clicked(object sender, System.EventArgs e)
{
try
{


SoundPlayer player = new SoundPlayer();
player.SoundLocation = WavFileName.Text;
player.Load();
player.Play();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}


}


===========================================================================­
=

Thank you in advance.


Best,


Raj.
 
G

Guest

I fail to understand the usefulness of this, since the only place the sound
will ever be played is on the server where it is run. Usually if you want to
play a sound in a web page for somebody not located on the server machine who
wants to hear it in their browser, you would use a client-side embed or
object tag to embed the media from the server into a player object in the
browser.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
 
R

Raj

Peter,

Thank you for your response. This is a simple test case I have
created for a bigger problem. Assuming the client and server are on
the same machine, any ideas on why this does not work on Vista, but
works flawlessly on other windows OSs?

Best,

Raj.
 
R

Rad [Visual C# MVP]

Experts,

I have a simple .aspx page that takes a path to a .wav file, and
plays it. This page works fine on all OSs (Windows 2000, Windows
2003,
Windows XP), but not on Vista. Could the protected mode on vista be
interfering with this page? Any other ideas on why the code does not
work on Vista would be greatly appreciated.

I acces thie page as http://localhost/WavFileTest.aspx, and enter "C:
\test.wav" as the path.

Hi Raj,

This sounds extremely convoluted to me. I presume you want the client
to hear the sound after login. If I were you I'd use some other
technique to get the sound to play. Personally I'd use Flash or
Silverlight instead of the approach you've taken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top