Hello,
I have the following problem.
The Windows MediaPlayer object is embedded in an ASP page:
--- test.asp ---------------------------
<%@ LANGUAGE=VBScript enablesessionstate=true LCID=1033 %>
<% option explicit %>
<html>
<body>
<h2>TEST</h2>
<embed type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
src="test2.asp?fn=test.wav"
width=320
height=69
name="MediaPlayer"
autostart="False"
ShowStatusBar=1
ShowDisplay=0
ShowControls=1>
</embed>
</body>
</html>
-------------------------------
The src parameter of the MediaPlayer object references to another ASP
script
which returns WAV file as a binary stream:
--- test2.asp ----------------------------
<%@ LANGUAGE=VBScript enablesessionstate=true LCID=1033 %>
<% option explicit %>
<%
Dim fn
fn = Request.QueryString("fn")
if not isNull(fn) and fn <"" then
Dim vpath, path, strExt, strContentType
vpath = "logs"
path = Server.MapPath(vpath)
strExt = LCase(GetFileExtension(fn))
if strExt = "mp3" then
strContentType = "audio/mp3"
else
strContentType = "audio/wav"
end if
Dim strFilePath
strFilePath = path & "\" & fn 'This is the path to the file on disk.
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile strFilePath
Response.AddHeader "Content-Type", strContentType
Response.AddHeader "Content-Disposition", "inline; filename=" & fn
Response.AddHeader "Accept-Ranges", "bytes"
Response.AddHeader "Content-Length", CStr(objStream.Size)
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
end if
Function GetFileExtension(fn)
Dim strExt, intExtPos
strExt = ""
intExtPos = InstrRev(fn, ".")
if (not IsNull(intExtPos)) and intExtPos 0 then
strExt = Mid(fn, intExtPos + 1)
end if
GetFileExtension = strExt
End Function
%>
-------------------------------
For some strange reason the web site receives 2 get requests:
one from the MediaPlayer object and the other from the browser itself:
2006-07-03 08:44:32 192.168.X.X - 192.168.X.X 80 GET /test.asp - 200 0
1018
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.N ET+CLR+1.1.4322)
2006-07-03 08:44:32 192.168.X.X - 192.168.X.X 80 GET /test2.asp
fn=test.wav 200 0 119682 Windows-Media-Player/9.00.00.3250
2006-07-03 08:44:32 192.168.X.X - 192.168.X.X 80 GET /test2.asp
fn=test.wav 200 0 119682
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.N ET+CLR+1.1.4322)
However, if the src parameter references a direct link to
a static WAV file on the server (src="test.wav"), then the browser
sends one GET request (form the MediaPlayer):
2006-07-03 08:45:05 192.168.X.X - 192.168.X.X 80 GET /test.asp - 200 0
1005
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.N ET+CLR+1.1.4322)
2006-07-03 08:45:05 192.168.X.X - 192.168.X.X 80 GET /test.wav - 200 0
119635 Windows-Media-Player/9.00.00.3250
How can I eliminate the extra request?