468,761 Members | 1,731 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,761 developers. It's quick & easy.

Play Sound Clip Once

Hi,

I recently received a task to have a .wav file play only once when home
page is 1st loaded and only play again when the user re-visits the page
by opening a new browser.

I am using asp.net 2.0 framework. Could someone please guide me?

Thank you.

Sep 27 '06 #1
3 3044
I'd suggest you read this detailed article I wrote about the subject, and
perhaps use of the included controls to solve your problem.
http://SteveOrr.net/articles/StreamingMedia.aspx

--
I hope this helps,
Steve C. Orr
MCSD, MVP, CSM
http://SteveOrr.net
"illmagination" <he********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hi,

I recently received a task to have a .wav file play only once when home
page is 1st loaded and only play again when the user re-visits the page
by opening a new browser.

I am using asp.net 2.0 framework. Could someone please guide me?

Thank you.

Sep 28 '06 #2
Hi,

I'd use a Session variable and output the client-side code programmatically.

The code below checks for the Session variable "Played". If the value is not
1, output the code to play the sound. Then set the Session variable to 1. As
long as the session is alive (that is, until the user leaves the site for 20
minutes [default] or closes the browser), the sound won't play again.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>

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

<script runat="server">

Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
If Not (Session("Played") = 1) Then
Page.ClientScript.RegisterStartupScript _
(Me.GetType, "sound", "<embed autostart='true' height='0' " & _
"loop='false' src='http://www.devx.com/assets/devx/8990.mid' " &
_
" width='0'></embed>", False)
Session("Played") = 1
End If
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Play a sound once</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
"illmagination" <he********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hi,

I recently received a task to have a .wav file play only once when home
page is 1st loaded and only play again when the user re-visits the page
by opening a new browser.

I am using asp.net 2.0 framework. Could someone please guide me?

Thank you.

Sep 28 '06 #3
Thank you but I was able to take care of it by writing to the code
behind

please see below

protected void Page_Load(object sender, EventArgs e)
{
if (Convert.ToString(Page.Session["MediaPlay"]) == "")
{
this.Page.Response.Write("<bgsound
src='/sound/Welcome.wav'>");
this.Page.Session["MediaPlay"] = "TRUE";
}
}


illmagination wrote:
Hi,

I recently received a task to have a .wav file play only once when home
page is 1st loaded and only play again when the user re-visits the page
by opening a new browser.

I am using asp.net 2.0 framework. Could someone please guide me?

Thank you.
Sep 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

22 posts views Thread by The Road To Utopia | last post: by
1 post views Thread by Ron Provost | last post: by
2 posts views Thread by Les Juby | last post: by
1 post views Thread by Lam | last post: by
16 posts views Thread by Chris Ianson | last post: by
1 post views Thread by illmagination | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.