Results 1 to 15 of 15

Thread: location

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678

    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

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Try this
    VB Code:
    1. Server.MapPath(""\WavFiles\202.wav" )
    Dont gain the world and lose your soul

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678

    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

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Did you try what Devgrp suggested?

    Or if you want to keep your same structure then try this:
    VB Code:
    1. Private Function WavPath(file As String) As String
    2.     Return Server.MapPath("\WavFiles\" & file)
    3. End Function
    4.  
    5. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.     If Not Page.IsPostBack Then
    7.        PlayWav(WavPath("202.wav"))
    8.     End If
    9. End Sub

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678
    Hi Edneeis,
    When I try your code at home it does not work and it still does not work on the internet either:-(
    :-(
    Thanks

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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"))

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678
    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

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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?

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678
    Yes that is correct.
    And in WavFiles is the .wav file which has to play. Thanks

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678
    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

  11. #11
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678
    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

  13. #13
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678
    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

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678
    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
  •  



Click Here to Expand Forum to Full Width