ADODB.Stream crashes IE
Posted on 2005-04-29
On our website we've got a flash player that streams MP3's, the flash player is fed using an ASP script that streams the MP3 as binary data. Using Internet Explorer, and after listening to a few songs, the browser first of all becomes sluggish and then crashes. This only happens when the songs is not allowed to finish, normally when the song finishes, the flash player clears the memory of any data that has been sent to it...The player appears in a pop-up window, if the user clicks on the normal 'X' button to close the window, the flash player cannot clear the memory. I am trying to figure out whether the script i am using to stream the data will continue executing even if the calling object, i.e. the flash player, has been closed.
Within my code, can anyone see any problems in the code, or the potential for the script to continue executing even when the calling object is no longer making calls to it??
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.CacheControl = "no-cache"
'declare file variables
Dim strPath, strFile, strExt
Dim bolIsError, strError
'assign values to variables
strPath = Server.MapPath("/mp3/")
strFile = Request.QueryString("qryFile")
strExt = LCase(Right(strFile,Len(strFile)-inStr(strFile,".")+1))
bolIsFlashCall = Request.Form("encryption")
'//Purpose: To return the file object to playlist.asp
Public Sub GetFile(strFile)
'check a valid filename was provided
If (strFile = "" Or strExt = "") Or (strExt <> "" And strExt = ".wma") Then
bolIsError = True
'only continue if a file has been provided
If bolIsError = False Then
'create an instance of the filesystem object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'only continue if the file exists
If objFso.FileExists(strPath & "\" & strFile) Then
'get a handle on the file
Set sFile = objFSO.GetFile(strPath & "\" & strFile)
'get the size of the file in bytes
lFileSize = sFile.Size
'create an instance of the stream object
Set objStream = Server.CreateObject("ADODB.Stream")
'open the stream
' Set the Stream to Binary (not Text)
objStream.Type = 1
'load the content of the MP3/Video into the stream object
objStream.LoadFromFile(strPath & "\" & strFile)
'change the HTTP header to reflect that a binary file is being passed.
Response.Expires = 0
Response.Buffer = True
'set the correct content type depending on the media type
Select Case strExt
Response.ContentType = "audio/octet-stream"
Response.ContentType = "video/octet-stream"
Response.AddHeader "Content-Disposition", "inline;filename=temp" & int(rnd()*9999999999) & strExt
Response.AddHeader "Content-Length", lFileSize
Response.CharSet = "UTF-8"
' While...Wend to send bulk of file
While lFileSize > lBlockSize + lCount And Response.IsClientConnected = True
lCount = lCount + lBlockSize
' Make sure each Block is sent before sending the next one
' Main bulk of file now sent - Just the last bit to go...
Response.BinaryWrite objStream.Read(lFileSize - lCount)
' Don't forget to flush that last little bit
'close all objects
Set objFso = Nothing
Set objStream = Nothing
Set sFile = Nothing
'do not execute any further
End If 'end if file exists
Any help would be greatly appreciated.....
Thanks in advance