Vista problem with playing .wav files from C#

Discussion in 'ASP .Net' started by rnmalhotra@gmail.com, Aug 16, 2007.

  1. Guest

    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. The (simple) code for this
    page is

    ==========.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>


    ======================= .cs code behind
    code======================================
    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.
    , Aug 16, 2007
    #1
    1. Advertising

  2. You doing it wrong.
    You playing it on the server. Why do you want to do that. It works for you
    only because you are sitting in the same room where server is :)


    George.


    <> wrote in message
    news:...
    > 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. The (simple) code for this
    > page is
    >
    > ==========.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>
    >
    >
    > ======================= .cs code behind
    > code======================================
    > 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.
    >
    George Ter-Saakov, Aug 16, 2007
    #2
    1. Advertising

  3. Raj Guest

    George,

    Thanks for the note. That is the intent, becuase the client and
    the server are always on the same machine. Any ideas on why it doesn't
    work on Vista?

    Best,
    Raj.

    On Aug 16, 12:59 pm, "George Ter-Saakov" <> wrote:
    > You doing it wrong.
    > You playing it on the server. Why do you want to do that. It works for you
    > only because you are sitting in the same room where server is :)
    >
    > George.
    >
    > <> wrote in message
    >
    > news:...
    >
    >
    >
    > > 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. The (simple) code for this
    > > page is

    >
    > > ==========.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>

    >
    > > ======================= .cs code behind
    > > code======================================
    > > 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.- Hide quoted text -

    >
    > - Show quoted text -
    Raj, Aug 16, 2007
    #3
  4. My educated guess would be that IIS does not have access to talk to
    speakers. Most likely it needs some elevated permissions to use the
    hardware.

    George.


    "Raj" <> wrote in message
    news:...
    George,

    Thanks for the note. That is the intent, becuase the client and
    the server are always on the same machine. Any ideas on why it doesn't
    work on Vista?

    Best,
    Raj.

    On Aug 16, 12:59 pm, "George Ter-Saakov" <> wrote:
    > You doing it wrong.
    > You playing it on the server. Why do you want to do that. It works for you
    > only because you are sitting in the same room where server is :)
    >
    > George.
    >
    > <> wrote in message
    >
    > news:...
    >
    >
    >
    > > 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. The (simple) code for this
    > > page is

    >
    > > ==========.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>

    >
    > > ======================= .cs code behind
    > > code======================================
    > > 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.- Hide quoted text -

    >
    > - Show quoted text -
    George Ter-Saakov, Aug 16, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Chalk

    Playing a WAV file from a Web Page

    Andrew Chalk, Nov 17, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    947
    Andrew Chalk
    Nov 17, 2005
  2. Ryan Kremser
    Replies:
    1
    Views:
    650
    Thomas Matthews
    Oct 27, 2003
  3. AM
    Replies:
    0
    Views:
    320
  4. '2+
    Replies:
    2
    Views:
    486
  5. Stewart

    playing wav files in netscape

    Stewart, May 4, 2006, in forum: Javascript
    Replies:
    0
    Views:
    75
    Stewart
    May 4, 2006
Loading...

Share This Page