|
-
May 1st, 2003, 04:45 PM
#1
Thread Starter
Fanatic Member
location
Hello,
I am facing problems pointing to the necessary files which are located on a web hosting company.
Currently there is a folder called WavFiles which has the .wav files in it.
Is it correct to access it using:
Server.MapPath(Request.ApplicationPath) & "\WavFiles\202.wav"
The reason I ask is because the filie does not play.
I am totally sure that the there is no problem with the .wav because it runs on the local web server at home.
Thank you
-
May 1st, 2003, 05:27 PM
#2
Frenzied Member
Try this
VB Code:
Server.MapPath(""\WavFiles\202.wav" )
Dont gain the world and lose your soul
-
May 2nd, 2003, 05:00 PM
#3
Thread Starter
Fanatic Member
location
Hi,
I have been working on the same location path issue fo rsometime now. Using the path as below plays the .wav fine wheras on the web hosting company it just doesn't.
Here is what I have.
Private Function WavPath() As String
Return Server.MapPath(Request.ApplicationPath) & "\WavFiles\"
End Function
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
PlayWav(WavPath() & "202.wav")
End If
End Sub
CAn you see what the problem is?
Thanks
-
May 2nd, 2003, 05:08 PM
#4
Did you try what Devgrp suggested?
Or if you want to keep your same structure then try this:
VB Code:
Private Function WavPath(file As String) As String
Return Server.MapPath("\WavFiles\" & file)
End Function
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
PlayWav(WavPath("202.wav"))
End If
End Sub
-
May 2nd, 2003, 05:25 PM
#5
Thread Starter
Fanatic Member
Hi Edneeis,
When I try your code at home it does not work and it still does not work on the internet either:-(
:-(
Thanks
-
May 2nd, 2003, 05:28 PM
#6
Is the WavFiles folder a subdirectory of another one other than the root? Also is it included in the aps.net project, not sure if that one matters?
/Wavfiles means that the WavFiles folder is in the webs root folder.
For testing purposes try adding this to the pageload event.
response.write(Server.MapPath("\wavFiles\202.wav"))
-
May 2nd, 2003, 06:04 PM
#7
Thread Starter
Fanatic Member
When running Response.Write(Server.MapPath(Request.ApplicationPath))
in the load event it shows e:\home\fmardani\
I should also mention that in fmardani there is a folder called wavfiles which contains the .wav files.
In fmardani is the .aspx
Does this help?
Thanks
-
May 2nd, 2003, 06:45 PM
#8
What does response.write(server.mappath("\")) return?
See you need to find the physical path of the root of the web.
Is the WavFiles folder located at: e:\home\fmardani\WavFiles?
-
May 3rd, 2003, 01:42 AM
#9
Thread Starter
Fanatic Member
Yes that is correct.
And in WavFiles is the .wav file which has to play. Thanks
-
May 3rd, 2003, 01:48 AM
#10
Thread Starter
Fanatic Member
Running :
Response.Write(Server.MapPath("\"))
Response.Write(Server.MapPath(Request.ApplicationPath) & "<br>")
Response.Write(Server.MapPath("/WavFiles") & "<br>")
Response.Write(Server.MapPath("\WavFiles") & "<br>")
Response.Write(Server.MapPath("WavFiles") & "<br>")
Response.Write(Server.MapPath("WavFiles\202.wav") & "<br>")
Response.Write(Server.MapPath("WavFiles/202.wav") & "<br>")
Response.Write(Server.MapPath("\WavFiles\202.wav") & "<br>")
Response.Write(Server.MapPath("/WavFiles/202.wav") & "<br>")
Response.Flush()
Response.End()
Produces...
e:\home\fmardani\e:\home\fmardani\
e:\home\fmardani\WavFiles
e:\home\fmardani\WavFiles
e:\home\fmardani\WavFiles
e:\home\fmardani\WavFiles\202.wav
e:\home\fmardani\WavFiles\202.wav
e:\home\fmardani\WavFiles\202.wav
e:\home\fmardani\WavFiles\202.wav
-
May 3rd, 2003, 04:21 AM
#11
So it looks like the path isn't the problem. What is your code for getting the file to play? The problem must be in there.
-
May 3rd, 2003, 09:49 AM
#12
Thread Starter
Fanatic Member
Please remember that everything is fine on the home machine. The problem is when it is on the web.
Any way when using :
Response.Write(Request.PhysicalApplicationPath & "\WavFiles\")
it returns:
e:\home\fmardani\\WavFiles\
Up to now it works fine.
As for the code that I am using:
Private Declare Auto Function PlaySound Lib "winmm.dll" _
(ByVal lpszSoundName As String, ByVal hModule As Integer, _
ByVal dwFlags As Integer) As Integer
Private Const SND_FILENAME As Integer = &H20000
Private Function WavPath(ByVal file As String) As String
Return Request.PhysicalApplicationPath & "\WavFiles\" & file
End Function
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
PlayWav(WavPath("202.wav"))
DisableButtons()
End If
End Sub
Thanks
-
May 3rd, 2003, 01:10 PM
#13
So you are saying if you run this on the local machine you hear the sound. Are you using the same machine for browsing and servering. It seems to me that there is a flaw in your code. You see ASP.NET runs server side so your code will play the sound on the server. That is why it works on your local machine, because your local machine is also the host, which is what plays the sound, not the client. But when you try it on the Web you don't error the sound because it would be played on the server machine. I think you'll need to use some sort of web way through html) to play the sound if you want the client to hear it.
-
May 3rd, 2003, 01:20 PM
#14
Thread Starter
Fanatic Member
Your explanation makes sense and I do want the client to hear it.
But i do not know how. Any way I am reading an article in msdn
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/vb_player_article.asp
I wonder if it can give some clues.
Thanks
-
May 3rd, 2003, 02:04 PM
#15
Thread Starter
Fanatic Member
Ok everybody.
It works now.
This is what you have to do in the event procedure
Response.Write("<bgsound src='WavFiles/202.wav' id='bgs202' loop='1'>")
As someone pointed out. It seems that using the API for this requirement is not right.
Html has to be used.
Thanks ever so much for your time guys.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|