Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2005, 02:25 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default Flash or Movies in ASP.NET

Hello,
I need to use flash or movies on my ASP.NET page. I am keeping the data for those files in the BLOB data field on ORACLE database. Do you have any example how to retrieve data from ORACLE to show on the page?

I try to use this code, but it requires a physical path to the file.
I need get data from the database:

Imports Osmosis.Web.UI.Controls.FlashMovie

Dim movie As Osmosis.Web.UI.Controls.FlashMovie
Dim sPhysicalAppPath As String

sPhysicalAppPath = Request.PhysicalApplicationPath.ToString()
movie = New Osmosis.Web.UI.Controls.FlashMovie
movie.FlashOutputType = Osmosis.Web.UI.FlashOutputType.ClientScriptVersion Dection

movie.MovieName = sPhysicalAppPath + "/fish.swf"

movie.MajorPluginVersion = 7
movie.MajorPluginVersionRevision = 0
movie.MinorPluginVersion = 0
movie.MinorPluginVersionRevision = 0
movie.MovieHeight = "85px"
movie.MovieWidth = "85px"
movie.AutoLoop = True
movie.AutoPlay = True

movie.MovieVariables.Add("MyVar1", "MyValue1")
movie.MovieVariables.Add("MyVar2", "MyValue2")
movie.MovieVariables.Add("MyVar3", "MyValue3")

PlaceHolder1.Controls.Add(movie)

movie.Dispose()
movie = Nothing

Any help and suggestions will be nice.
Thanks
    Dmitriy :)
 
Old June 29th, 2005, 09:35 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

When it comes to display other media types on a web page, there is typically little to do involving the server-side aspect of the page on which it will be shown. The media elements will simply be HTML elements that have source file references (such as an object tag that references a source swf file on your server). In the case of having the media data stored in a database, things get a little more complicated. You can probably find many examples of writing a server page that actually serves up the binary data for some media resource. You emit standard HTML to the page that will contain the resource and you point the resource to this server file URL. An example of this would be a database with images stored in it. The image tag looks like this: <img src="image.aspx?imageID=1234" />. When the browser starts to load the image it calls that URL which calls the database, gets the binary data for image 1234 and supplies it back to the HTTP response stream using the Response.BinaryWrite() method. The same concept would apply to virtually any media type. You will just need to supply the right mime type in the response so the browser knows how to handle the data coming back.

-Peter
 
Old July 5th, 2005, 09:22 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 121
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Peter,
By some reason the method you described does not work. I've created the ASPX file with just one IMAGE box on it (MOVIETEST.ASPX) and specified as a SRC for the image box the name of second ASPX file (MOVIE.ASPX) to do all database work in the LOAD event. But what I see on the returned MOVIETEST.ASPX page is just empty image box. I've tested to display SWF file.
I am sending the code for MOVIE.ASPX file. What do you think I am doing wrong?

Imports System.Data
Imports System.Data.OleDb
Imports Oracle.DataAccess.Client

Public Class Movie
    Inherits System.Web.UI.Page

    Private wsDataBasesService As DataBasesService
    Private sErrorMessage As String

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim lBIOTA_ID As Long
        Dim lMovie_ID As Long
        Dim dr As OracleDataReader
        Dim cmd As OracleCommand
        Dim oTmp As Object
        Dim i As Integer
        Dim k As Integer
        Dim sCommandText As String 'the command text string
        Dim iPos As Integer
        Dim iLen As Integer
        Dim lReturn As Long
        Dim sTmp As String
        Dim sFileExtention As String
        Dim sFileName As String
        Dim byteData As Byte()
        Dim lLength As Long

        'initialization:
        sErrorMessage = ""

        '''''lBIOTA_ID = CLng(Session("BIOTA_ID")) 'LIVE!!!!!!!!!!!!!!!!!!!!!!!!!!!
        '''''lMovie_ID = CLng(Session("MOVIE_ID")) 'LIVE!!!!!!!!!!!!!!!!!!!!!!!!!!!
        lBIOTA_ID = 8290 'FOR TEST ONLY!!!!!!!!!!!!!!!!!!!!!!!
        lMovie_ID = 1 'FOR TEST ONLY!!!!!!!!!!!!!!!!!!!!!!!

        'Create the connection to the datasource:
        'wsDataBasesService = New DataBaseWebService.DataBasesService
        wsDataBasesService = New DataBasesService
        If wsDataBasesService.LAZARUS_OpenConnection("USERID" , "PASSWORD") = 1 Then
            Try
                sCommandText = "SELECT f.MOVIE_OBJECT,f.MOVIE_OBJECT_NAME,f.MOVIE_OBJECT_ SIZE FROM LAZARUS.MEDIAMOVIE f WHERE f.BIOTA_ID=" & CStr(lBIOTA_ID) & " AND f.MOVIE_ID=" & CStr(lMovie_ID) & ""
                cmd = New OracleCommand(sCommandText, CType(wsDataBasesService.GetLAZARUSConnection(), OracleConnection))
                dr = cmd.ExecuteReader(CommandBehavior.Default)
                While (dr.Read = True)
                    'iterate over all fields:
                    For i = 0 To dr.FieldCount - 1
                        Select Case dr.GetName(i)
                            Case "MOVIE_OBJECT"
                                If Not dr.GetValue(i) Is DBNull.Value Then
                                    'fetch the value of ORACLE field ito the byte-array:
                                    byteData = CType(dr.GetValue(i), Byte())
                                Else
                                    oTmp = Nothing
                                    cmd = Nothing
                                    If dr.IsClosed = False Then
                                        dr.Close()
                                    End If
                                    wsDataBasesService.LAZARUS_CloseConnection()
                                    wsDataBasesService = Nothing
                                    Exit Sub
                                End If
                            Case "MOVIE_OBJECT_SIZE"
                                If Not dr.GetValue(i) Is DBNull.Value Then
                                    If Not dr.GetValue(i) Is DBNull.Value Then
                                        lLength = CType(dr.GetValue(i), Long)
                                    End If
                                End If
                            Case "MOVIE_OBJECT_NAME"
                                If Not dr.GetValue(i) Is DBNull.Value Then
                                    oTmp = CType(dr.GetValue(i), String)
                                    sFileName = oTmp
                                    iPos = InStrRev(sFileName, ".")
                                    If iPos <> 0 Then
                                        sFileExtention = Mid(sFileName, iPos + 1)
                                        'do clean up:
                                        oTmp = Nothing
                                    Else
                                        'do clean up:
                                        oTmp = Nothing
                                        cmd = Nothing
                                        If dr.IsClosed = False Then
                                            dr.Close()
                                        End If
                                        wsDataBasesService.LAZARUS_CloseConnection()
                                        wsDataBasesService = Nothing
                                        Response.WriteFile("SorryNoImagePage.asp")
                                        Exit Sub
                                    End If
                                Else
                                    oTmp = Nothing
                                    cmd = Nothing
                                    If dr.IsClosed = False Then
                                        dr.Close()
                                    End If
                                    wsDataBasesService.LAZARUS_CloseConnection()
                                    wsDataBasesService = Nothing
                                    Response.WriteFile("SorryNoImagePage.asp")
                                    Exit Sub
                                End If
                            Case Else
                                'do clean up...
                                oTmp = Nothing
                                cmd = Nothing
                                If dr.IsClosed = False Then
                                    dr.Close()
                                End If
                                wsDataBasesService.LAZARUS_CloseConnection()
                                wsDataBasesService = Nothing
                                Session("Message") = "ERROR on reading field values with DataReader. Contact customer support,please. "
                                Response.Redirect("ErrorForm.aspx", False)
                                Exit Sub
                        End Select
                        'do clean up...
                        oTmp = Nothing
                    Next
                End While

                'Display the contents of the record as an image:

                Response.Expires = 0
                Response.Buffer = True
                Response.Clear()

                If UCase(sFileExtention) = "GIF" Then
                    Response.ContentType = "image/gif"
                ElseIf UCase(sFileExtention) = "JPEG" Or UCase(sFileExtention) = "JPG" Then
                    Response.ContentType = "image/jpeg"
                ElseIf UCase(sFileExtention) = "PDF" Then
                    Response.ContentType = "text/html"
                ElseIf UCase(sFileExtention) = "AVI" Then
                    Response.ContentType = "video/x-msvideo"
                ElseIf UCase(sFileExtention) = "SWF" Then
                    Response.ContentType = "application/x-shockwave-flash"
                End If
                Response.BinaryWrite(byteData)
                '''''Response.End()


                'do clean up...
                oTmp = Nothing
                cmd = Nothing
                If dr.IsClosed = False Then
                    dr.Close()
                End If
                wsDataBasesService.LAZARUS_CloseConnection()
                wsDataBasesService = Nothing
            Catch ex As Exception
                'do clean up...
                If Not wsDataBasesService.GetLAZARUSConnection() Is Nothing Then
                    If wsDataBasesService.LAZARUS_ConnectionState() = 1 Then
                        If dr.IsClosed = False Then
                            dr.Close()
                            dr.Dispose()
                        End If
                        wsDataBasesService.LAZARUS_CloseConnection()
                        wsDataBasesService.Dispose()
                        wsDataBasesService = Nothing
                    End If
                End If
                cmd = Nothing
                'ERROR on reading field values with DataReader
                Session("Message") = ex.Message
                Response.Redirect("ErrorForm.aspx", False)
                Exit Sub
            End Try
        Else
            'ERROR opening the connection to the DataSource
            Session("Message") = "ERROR opening the connection to the DataSource. Contact customer support,please. "
            Response.Redirect("ErrorForm.aspx", False)
            Exit Sub
        End If
    End Sub

End Class

The "DataBasesService" is the separate class I've created to do all database related jobs.

Thanks in advance,
   Dmitriy :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Flash Movies To Screensavers If Possible Ben Horne Flash (all versions) 7 December 15th, 2006 11:35 PM
Flash or Movies in ASP.NET Dmitriy General .NET 2 July 1st, 2005 04:16 AM
Flash or Movies in ASP.NET Dmitriy Pro VB 6 2 June 29th, 2005 09:38 PM
Flash or Movies in ASP.NET Dmitriy Classic ASP Professional 1 June 29th, 2005 09:37 PM
Flash Movies In Dreamweaver Ben Horne Dreamweaver (all versions) 1 February 11th, 2004 02:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.