the following code.
I need to be able to use either response.outpustream or
response.binarywrite since
I will be getting the file from an sql server image field. Other types
of files such as gif or pdf work fine. Here is the code for the wmv:
Dim sql As String
sql = "select * from TblBlobs where blob_id = " & iBlobId
Dim da As New SqlDataAdapter(sql, cn)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet
cn.Open()
da.Fill(ds, "Default")
Dim myRow As DataRow
myRow = ds.Tables("Default").Rows(0)
Dim MyData() As Byte
MyData = myRow("filedata")
Response.ClearContent()
Response.ClearHeaders()
Response.Buffer = False
Response.ContentType = "video/x-ms-wmv"
Response.OutputStream.Write(MyData, 0, MyData.Length)
Response.Flush()
Response.Close()
MyCB = Nothing
ds = Nothing
da = Nothing
cn.Close()
cn = Nothing
When the user clicks on a button to run this code, the error "The data
is invalid" is displayed from windows media player. I cannot figure
out what is specific about wmv's that they will not stream.
Thanks Before Hand,
AdielCAn you scesfully download the WMV file.
"adiel_g@dotnet.itags.org.hotmail.com" wrote:
> I cannot seem to get a wmv file to stream from asp.net. I have tried
> the following code.
> I need to be able to use either response.outpustream or
> response.binarywrite since
> I will be getting the file from an sql server image field. Other types
> of files such as gif or pdf work fine. Here is the code for the wmv:
>
> Dim sql As String
> sql = "select * from TblBlobs where blob_id = " & iBlobId
> Dim da As New SqlDataAdapter(sql, cn)
> Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
> Dim ds As New DataSet
> cn.Open()
> da.Fill(ds, "Default")
> Dim myRow As DataRow
> myRow = ds.Tables("Default").Rows(0)
> Dim MyData() As Byte
> MyData = myRow("filedata")
> Response.ClearContent()
> Response.ClearHeaders()
> Response.Buffer = False
> Response.ContentType = "video/x-ms-wmv"
> Response.OutputStream.Write(MyData, 0, MyData.Length)
> Response.Flush()
> Response.Close()
> MyCB = Nothing
> ds = Nothing
> da = Nothing
> cn.Close()
> cn = Nothing
>
> When the user clicks on a button to run this code, the error "The data
> is invalid" is displayed from windows media player. I cannot figure
> out what is specific about wmv's that they will not stream.
> Thanks Before Hand,
> Adiel
>
No, if I click on the link and choose "Save target as", the error is:
Internet Explorer cannot down from ... _ctl18$lnkLoadImageItem','').
I can understand the above error because the system has to call the
function before it can actually download the file. Basically the
function above is being called from a LinkButton. I have also tried
calling the function from a regular button and same results: I can load
gifs, pdfs, jpgs, etc but windows video files (wmv) receive the error
"The data is invalid" when the system starts Windows Media Player.
Update:
The error when testing on system with Windows Media Player Version
7.10.00.3077 is "The data is invalid"
The error when testing on system with Windows Media Player Version
10.00.00.3700 is "Windows Media Player cannot play the file. The
Player might not support the file type or might not support the codec
that was used to compress the file." and if you click on "More
Information", the error is "C00D1199: Cannot play the file" Error ID =
0xC00D1199, Condition ID = 0x00000000.
Thanks,
Adiel
0 comments:
Post a Comment