home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / DirectX8 / dx8vbsdk.exe / samples / multimedia / vbsamples / directshow / editing / slideshowvb / moddexter.bas < prev    next >
Encoding:
BASIC Source File  |  2000-09-22  |  66.0 KB  |  1,311 lines

  1. Attribute VB_Name = "modDexter"
  2. '*******************************************************************************
  3. '*       This is a part of the Microsoft DXSDK Code Samples.
  4. '*       Copyright (C) 1999-2000 Microsoft Corporation.
  5. '*       All rights reserved.
  6. '*       This source code is only intended as a supplement to
  7. '*       Microsoft Development Tools and/or SDK documentation.
  8. '*       See these sources for detailed information regarding the
  9. '*       Microsoft samples programs.
  10. '*******************************************************************************
  11. Option Explicit
  12. Option Base 0
  13. Option Compare Text
  14.  
  15. 'user for async rendering procedures
  16. Private m_objMediaEvent As IMediaEvent
  17. Private m_objFilterGraph As IGraphBuilder
  18. Private m_objRenderEngine As RenderEngine
  19. Private m_objFilterGraphManager As New FilgraphManager
  20.  
  21.  
  22. ' **************************************************************************************************************************************
  23. ' * PUBLIC INTERFACE- ENUMERATIONS
  24. ' *
  25. ' *
  26.             'supported export formats
  27.             Public Enum DEXExportFormatEnum
  28.             DEXExportXTL = 0
  29.             DEXExportGRF = 1
  30.             End Enum
  31.  
  32.             'supported import formats
  33.             Public Enum DEXImportFormatEnum
  34.             DEXImportXTL = 0
  35.             End Enum
  36.             
  37.             'supported media groups
  38.             Public Enum DEXMediaTypeEnum
  39.             DEXMediaTypeAudio = 1
  40.             DEXMediaTypeVideo = 0
  41.             End Enum
  42.             
  43.             
  44.  
  45. ' **************************************************************************************************************************************
  46. ' * PUBLIC INTERFACE- DEXTER PROCEDURES
  47. ' *
  48. ' *
  49.             ' ******************************************************************************************************************************
  50.             ' * procedure name: ClearTimeline
  51.             ' * procedure description: purges the given timeline of all groups
  52.             ' *                                      NOTE: YOU MUST CALL THIS ON ANY AMTIMELINES YOU HAVE BEFORE RELEASING
  53.             ' *                                      THEM (e.g. BEFORE YOUR APP SHUTS DOWN) OR SO AS TO FREE MEMORY RESOURCES
  54.             ' ******************************************************************************************************************************
  55.             Public Sub ClearTimeline(objTimeline As AMTimeline)
  56.             On Local Error GoTo ErrLine
  57.              
  58.             If ObjPtr(objTimeline) > 0 Then
  59.                Call objTimeline.ClearAllGroups
  60.             End If
  61.             Exit Sub
  62.             
  63. ErrLine:
  64.             Err.Clear
  65.             Exit Sub
  66.             End Sub
  67.             
  68.             
  69.             ' ******************************************************************************************************************************
  70.             ' * procedure name: SaveTimeline
  71.             ' * procedure description:  Persists a timeline to a file given the specified format
  72.             ' *
  73.             ' ******************************************************************************************************************************
  74.             Public Sub SaveTimeline(objTimeline As AMTimeline, bstrFileName As String, Optional Format As DEXExportFormatEnum = DEXExportXTL)
  75.             Dim objXml2Dex As Xml2Dex
  76.             Dim objFilterGraph As IGraphBuilder
  77.             Dim objRenderEngine As RenderEngine
  78.             On Local Error GoTo ErrLine
  79.             
  80.             If ObjPtr(objTimeline) > 0 Then
  81.                Select Case LCase(Format)
  82.                     Case DEXExportFormatEnum.DEXExportXTL
  83.                         'Persist the timeline using the dexter XTL File Format
  84.                         Set objXml2Dex = New Xml2Dex
  85.                         objXml2Dex.WriteXMLFile objTimeline, bstrFileName
  86.                         
  87.                     Case DEXExportFormatEnum.DEXExportGRF
  88.                         'Persist the timeline to a DShow Filter Graph Format
  89.                         Set objXml2Dex = New Xml2Dex
  90.                         Set objRenderEngine = New RenderEngine
  91.                         Call objRenderEngine.SetTimelineObject(objTimeline)
  92.                         Call objRenderEngine.ConnectFrontEnd
  93.                         Call objRenderEngine.RenderOutputPins
  94.                         Call objRenderEngine.GetFilterGraph(objFilterGraph)
  95.                         objXml2Dex.WriteGrfFile objFilterGraph, bstrFileName
  96.                End Select
  97.             End If
  98.             
  99.             'clean-up & dereference
  100.             If ObjPtr(objXml2Dex) > 0 Then Set objXml2Dex = Nothing
  101.             If ObjPtr(objFilterGraph) > 0 Then Set objFilterGraph = Nothing
  102.             If ObjPtr(objRenderEngine) > 0 Then Set objRenderEngine = Nothing
  103.             Exit Sub
  104.             
  105. ErrLine:
  106.             Err.Clear
  107.             Exit Sub
  108.             End Sub
  109.  
  110.  
  111.             
  112.             ' ******************************************************************************************************************************
  113.             ' * procedure name: RestoreTimeline
  114.             ' * procedure description:  Restores a timeline from a file given the specified format
  115.             ' *
  116.             ' ******************************************************************************************************************************
  117.             Public Sub RestoreTimeline(objTimeline As AMTimeline, bstrFileName As String, Optional Format As DEXImportFormatEnum = DEXImportXTL)
  118.             Dim objXml2Dex As Xml2Dex
  119.             On Local Error GoTo ErrLine
  120.             
  121.             If ObjPtr(objTimeline) > 0 Then
  122.                Select Case LCase(Format)
  123.                     Case DEXImportFormatEnum.DEXImportXTL
  124.                         'restore the timeline from a dexter XTL File Format
  125.                         Set objXml2Dex = New Xml2Dex
  126.                         Call objXml2Dex.ReadXMLFile(objTimeline, bstrFileName)
  127.                End Select
  128.             End If
  129.             
  130.             'clean-up & dereference
  131.             If ObjPtr(objXml2Dex) > 0 Then Set objXml2Dex = Nothing
  132.             Exit Sub
  133.             
  134. ErrLine:
  135.             Err.Clear
  136.             Exit Sub
  137.             End Sub
  138.             
  139.             
  140.             
  141.             ' ******************************************************************************************************************************
  142.             ' * procedure name: CreateTimeline
  143.             ' * procedure description:  creates a AMTimeline object
  144.             ' *
  145.             ' ******************************************************************************************************************************
  146.             Public Function CreateTimeline() As AMTimeline
  147.             On Local Error GoTo ErrLine
  148.             'instantiate return value direct
  149.             Set CreateTimeline = New AMTimeline
  150.             Exit Function
  151.             
  152. ErrLine:
  153.             Err.Clear
  154.             Exit Function
  155.             End Function
  156.             
  157.             
  158.             
  159.             ' ******************************************************************************************************************************
  160.             ' * procedure name: CreateGroup
  161.             ' * procedure description:  creates a group object given the passed properties (group name & mediatype)  on the given timeline
  162.             ' *                                       groups can only be inserted into a timeline; so you could use this function with 'InsertGroup' typically
  163.             ' ******************************************************************************************************************************
  164.             Public Function CreateGroup(objTimeline As AMTimeline, bstrGroupName As String, MediaType As DEXMediaTypeEnum, Optional OutputFPS As Double = 15, Optional PreviewMode As Long, Optional OutputBuffer As Long = 32) As AMTimelineGroup
  165.             Dim objGroup As AMTimelineGroup
  166.             Dim objTimelineObject As AMTimelineObj
  167.             On Local Error GoTo ErrLine
  168.             
  169.             'create an empty node on the timeline
  170.             objTimeline.CreateEmptyNode objTimelineObject, TIMELINE_MAJOR_TYPE_GROUP
  171.             'derive the group interface
  172.             Set objGroup = objTimelineObject
  173.             'set the name of the group
  174.             Call objGroup.SetGroupName(bstrGroupName)
  175.             'set the media type for the group
  176.             Call objGroup.SetMediaTypeForVB(MediaType)
  177.             'set the output buffer for the group
  178.             Call objGroup.SetOutputBuffering(OutputBuffer)
  179.             'set the preview mode for the group
  180.             Call objGroup.SetPreviewMode(PreviewMode)
  181.             'set the output fps for the group
  182.             Call objGroup.SetOutputFPS(OutputFPS)
  183.             'return the group to the client
  184.             Set CreateGroup = objGroup
  185.             'clean-up & dereference
  186.             If ObjPtr(objGroup) > 0 Then Set objGroup = Nothing
  187.             If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  188.             Exit Function
  189.             
  190. ErrLine:
  191.             Err.Clear
  192.             Exit Function
  193.             End Function
  194.             
  195.             
  196.             
  197.             ' ******************************************************************************************************************************
  198.             ' * procedure name: CreateComposite
  199.             ' * procedure description: Creates a Composite object on the given timeline
  200.             ' *
  201.             ' ******************************************************************************************************************************
  202.             Public Function CreateComposite(objTimeline As AMTimeline) As AMTimelineComp
  203.             Dim objComp As AMTimelineComp
  204.             Dim objTimelineObject As AMTimelineObj
  205.             On Local Error GoTo ErrLine
  206.             
  207.             'create an empty node on the timeline
  208.             objTimeline.CreateEmptyNode objTimelineObject, TIMELINE_MAJOR_TYPE_COMPOSITE
  209.             'derive the composite interface
  210.             Set objComp = objTimelineObject
  211.             'return the group to the client
  212.             Set CreateComposite = objComp
  213.             'clean-up & dereference
  214.             If ObjPtr(objComp) > 0 Then Set objComp = Nothing
  215.             If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  216.             Exit Function
  217.             
  218. ErrLine:
  219.             Err.Clear
  220.             Exit Function
  221.             End Function
  222.             
  223.             
  224.             
  225.             ' ******************************************************************************************************************************
  226.             ' * procedure name: CreateTrack
  227.             ' * procedure description: Create a track object on the given timeline
  228.             ' *
  229.             ' ******************************************************************************************************************************
  230.             Public Function CreateTrack(objTimeline As AMTimeline) As AMTimelineTrack
  231.             Dim objTrack As AMTimelineTrack
  232.             Dim objTimelineObject As AMTimelineObj
  233.             On Local Error GoTo ErrLine
  234.             
  235.             'create an empty node on the timeline
  236.             objTimeline.CreateEmptyNode objTimelineObject, TIMELINE_MAJOR_TYPE_TRACK
  237.             'derive the track interface
  238.             Set objTrack = objTimelineObject
  239.             'return the track to the client
  240.             Set CreateTrack = objTrack
  241.             'clean-up & dereference
  242.             If ObjPtr(objTrack) > 0 Then Set objTrack = Nothing
  243.             If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  244.             Exit Function
  245.             
  246. ErrLine:
  247.             Err.Clear
  248.             Exit Function
  249.             End Function
  250.             
  251.             
  252.             
  253.             ' ******************************************************************************************************************************
  254.             ' * procedure name: CreateEffect
  255.             ' * procedure description: creates an effect object on the given timeline
  256.             ' *
  257.             ' ******************************************************************************************************************************
  258.             Public Function CreateEffect(objTimeline As AMTimeline) As AMTimelineEffect
  259.             Dim objEffect As AMTimelineEffect
  260.             Dim objTimelineObject As AMTimelineObj
  261.             On Local Error GoTo ErrLine
  262.             
  263.             'create an empty node on the timeline
  264.             objTimeline.CreateEmptyNode objTimelineObject, TIMELINE_MAJOR_TYPE_EFFECT
  265.             'derive the effect interface
  266.             Set objEffect = objTimelineObject
  267.             'return the group to the client
  268.             Set CreateEffect = objEffect
  269.             'clean-up & dereference
  270.             If ObjPtr(objEffect) > 0 Then Set objEffect = Nothing
  271.             If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  272.             Exit Function
  273.             
  274. ErrLine:
  275.             Err.Clear
  276.             Exit Function
  277.             End Function
  278.             
  279.             
  280.             
  281.             ' ******************************************************************************************************************************
  282.             ' * procedure name: CreateTransition
  283.             ' * procedure description: creates a transition object on the given timeline
  284.             ' *
  285.             ' ******************************************************************************************************************************
  286.             Public Function CreateTransition(objTimeline As AMTimeline) As AMTimelineTrans
  287.             Dim objTrans As AMTimelineTrans
  288.             Dim objTimelineObject As AMTimelineObj
  289.             On Local Error GoTo ErrLine
  290.             
  291.             'create an empty node on the timeline
  292.             objTimeline.CreateEmptyNode objTimelineObject, TIMELINE_MAJOR_TYPE_TRANSITION
  293.             'derive the effect interface
  294.             Set objTrans = objTimelineObject
  295.             'return the group to the client
  296.             Set CreateTransition = objTrans
  297.             'clean-up & dereference
  298.             If ObjPtr(objTrans) > 0 Then Set objTrans = Nothing
  299.             If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  300.             Exit Function
  301.             
  302. ErrLine:
  303.             Err.Clear
  304.             Exit Function
  305.             End Function
  306.             
  307.             
  308.             
  309.             ' ******************************************************************************************************************************
  310.             ' * procedure name: CreateSource
  311.             ' * procedure description: creates a clip/source object on the given timeline
  312.             ' *
  313.             ' ******************************************************************************************************************************
  314.             Public Function CreateSource(objTimeline As AMTimeline) As AMTimelineSrc
  315.             Dim objSrc As AMTimelineSrc
  316.             Dim objTimelineObject As AMTimelineObj
  317.             On Local Error GoTo ErrLine
  318.             
  319.             'create an empty node on the timeline
  320.             objTimeline.CreateEmptyNode objTimelineObject, TIMELINE_MAJOR_TYPE_SOURCE
  321.             'derive the source interface
  322.             Set objSrc = objTimelineObject
  323.             'return the source to the client
  324.             Set CreateSource = objSrc
  325.             'clean-up & dereference
  326.             If ObjPtr(objSrc) > 0 Then Set objSrc = Nothing
  327.             If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  328.             Exit Function
  329.             
  330. ErrLine:
  331.             Err.Clear
  332.             Exit Function
  333.             End Function
  334.             
  335.             
  336.             
  337.             ' ******************************************************************************************************************************
  338.             ' * procedure name: GroupFromTimeline
  339.             ' * procedure description:  Returns a group object given the passed arguments (timeline & group)
  340.             ' *                                       Groups can only be inserted into a timeline; use this function with 'InsertGroup'
  341.             ' ******************************************************************************************************************************
  342.             Public Function GroupFromTimeline(objTimeline As AMTimeline, Optional Group As Long = 0) As AMTimelineGroup
  343.             Dim objGroup As AMTimelineGroup
  344.             Dim objTimelineObject As AMTimelineObj
  345.             On Local Error GoTo ErrLine
  346.             
  347.             'obtain a Timeline Object from the timeline
  348.             Call objTimeline.GetGroup(objTimelineObject, Group)
  349.             'derive the group interface from the timeline object
  350.             Set objGroup = objTimelineObject
  351.             'returnt the reference to the client
  352.             Set GroupFromTimeline = objGroup
  353.             'clean-up & dereference
  354.             If ObjPtr(objGroup) > 0 Then Set objGroup = Nothing
  355.             If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  356.             Exit Function
  357.             
  358. ErrLine:
  359.             Err.Clear
  360.             Exit Function
  361.             End Function
  362.             
  363.             
  364.             ' ******************************************************************************************************************************
  365.             ' * procedure name: InsertGroup
  366.             ' * procedure description: appends a group to a timeline object; you can only append groups to a timeline
  367.             ' *
  368.             ' ******************************************************************************************************************************
  369.             Public Sub InsertGroup(objDestTimeline As AMTimeline, objSourceGroup As AMTimelineGroup)
  370.             Dim objTimelineObject As AMTimelineObj
  371.             On Local Error GoTo ErrLine
  372.             
  373.             If ObjPtr(objSourceGroup) > 0 Then
  374.                If ObjPtr(objDestTimeline) > 0 Then
  375.                   'query for the Timelineobj interface
  376.                   Set objTimelineObject = objSourceGroup
  377.                   'append the source group to the destination timeline
  378.                   objDestTimeline.AddGroup objTimelineObject
  379.                   'clean-up & dereference
  380.                   If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  381.                End If
  382.             End If
  383.             Exit Sub
  384.             
  385. ErrLine:
  386.             Err.Clear
  387.             Exit Sub
  388.             End Sub
  389.             
  390.             
  391.             
  392.             ' ******************************************************************************************************************************
  393.             ' * procedure name: InsertComposite
  394.             ' * procedure description: Inserts Composite into a group or into another composite,
  395.             ' *                                      The second argument, objInsetDestination evaluates to either a group or a composite object
  396.             ' ******************************************************************************************************************************
  397.             Public Sub InsertComposite(objSourceComposite As AMTimelineComp, objInsetDestination As AMTimelineObj, Optional Priority As Long = -1)
  398.             Dim objComp As AMTimelineComp
  399.             Dim objTimelineObject As AMTimelineObj
  400.             On Local Error GoTo ErrLine
  401.             
  402.             If ObjPtr(objSourceComposite) > 0 Then
  403.                If ObjPtr(objInsetDestination) > 0 Then
  404.                   'query for the composite interface
  405.                   Set objComp = objInsetDestination
  406.                   'query for the timelineobj object
  407.                   Set objTimelineObject = objSourceComposite
  408.                   'insert the comp into the group; or comp & set the priority
  409.                   Call objComp.VTrackInsBefore(objTimelineObject, Priority)
  410.                   'clean-up & dereference
  411.                   If ObjPtr(objComp) > 0 Then Set objComp = Nothing
  412.                   If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  413.                End If
  414.             End If
  415.             Exit Sub
  416.             
  417. ErrLine:
  418.             Err.Clear
  419.             Exit Sub
  420.             End Sub
  421.             
  422.             
  423.             
  424.             ' ******************************************************************************************************************************
  425.             ' * procedure name: InsertTrack
  426.             ' * procedure description: Inserts a track into a group or a composite,
  427.             ' *                                      The second argument, objInsetDestination evaluates to either a group or a composite
  428.             ' ******************************************************************************************************************************
  429.             Public Sub InsertTrack(objTrack As AMTimelineTrack, objInsetDestination As AMTimelineObj, Optional Priority As Long = -1)
  430.             Dim objComp As AMTimelineComp
  431.             Dim objTimelineObject As AMTimelineObj
  432.             On Local Error GoTo ErrLine
  433.             
  434.             If ObjPtr(objTrack) > 0 Then
  435.                If ObjPtr(objInsetDestination) > 0 Then
  436.                   'query for the composite interface
  437.                   Set objComp = objInsetDestination
  438.                   'query for the timelineobj object
  439.                   Set objTimelineObject = objTrack
  440.                   'insert the comp into the group; or comp & set the priority
  441.                   Call objComp.VTrackInsBefore(objTimelineObject, Priority)
  442.                   'clean-up & dereference
  443.                   If ObjPtr(objComp) > 0 Then Set objComp = Nothing
  444.                   If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  445.                End If
  446.             End If
  447.             Exit Sub
  448.             
  449. ErrLine:
  450.             Err.Clear
  451.             Exit Sub
  452.             End Sub
  453.             
  454.             
  455.             
  456.             ' ******************************************************************************************************************************
  457.             ' * procedure name: InsertEffect
  458.             ' * procedure description: appends an effect to a timeline object
  459.             ' *
  460.             ' ******************************************************************************************************************************
  461.             Public Sub InsertEffect(objSourceEffect As AMTimelineEffect, objInsetDestination As AMTimelineObj, bstrEffectCLSID As String, dblTStart As Double, dblTStop As Double, Optional Priority As Long = -1)
  462.             Dim objTimelineObject As AMTimelineObj
  463.             Dim objTimelineEffectable As IAMTimelineEffectable
  464.             On Local Error GoTo ErrLine
  465.             
  466.             If ObjPtr(objSourceEffect) > 0 Then
  467.                If ObjPtr(objInsetDestination) > 0 Then
  468.                   'query for the timelineobj object
  469.                   Set objTimelineObject = objSourceEffect
  470.                   Call objTimelineObject.SetSubObjectGUIDB(bstrEffectCLSID)
  471.                   Call objTimelineObject.SetStartStop2(dblTStart, dblTStop)
  472.                   'insert the effect into the destination
  473.                   Set objTimelineEffectable = objInsetDestination
  474.                   Call objTimelineEffectable.EffectInsBefore(objTimelineObject, Priority)
  475.                   'clean-up & dereference
  476.                   If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  477.                   If ObjPtr(objTimelineEffectable) > 0 Then Set objTimelineEffectable = Nothing
  478.                End If
  479.             End If
  480.             Exit Sub
  481.             
  482. ErrLine:
  483.             Err.Clear
  484.             Exit Sub
  485.             End Sub
  486.             
  487.         
  488.             
  489.             ' ******************************************************************************************************************************
  490.             ' * procedure name: InsertSource
  491.             ' * procedure description: inserts a source clip to a timeline object; you can only append source to a track
  492.             ' *
  493.             ' ******************************************************************************************************************************
  494.             Public Sub InsertSource(objDestTrack As AMTimelineTrack, objSourceClip As AMTimelineSrc, bstrMediaName As String, dblTStart As Double, dblTStop As Double, Optional dblMStart As Double, Optional dblMStop As Double)
  495.             Dim objTimelineObject As AMTimelineObj
  496.             On Local Error GoTo ErrLine
  497.             
  498.             If ObjPtr(objDestTrack) > 0 Then
  499.                If ObjPtr(objSourceClip) > 0 Then
  500.                   'set the media name
  501.                   Call objSourceClip.SetMediaName(bstrMediaName)
  502.                   'query for the Timelineobj interface
  503.                   Set objTimelineObject = objSourceClip
  504.                   'set start/stop times
  505.                   Call objTimelineObject.SetStartStop2(dblTStart, dblTStop)
  506.                   If dblMStart >= 0 And dblMStop <> 0 Then
  507.                      'set the media times
  508.                      Call objSourceClip.SetMediaTimes2(dblMStart, dblMStop)
  509.                   End If
  510.                   'append the source clip to the destination track
  511.                   objDestTrack.SrcAdd objTimelineObject
  512.                   'clean-up & dereference
  513.                   If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  514.                End If
  515.             End If
  516.             Exit Sub
  517.             
  518. ErrLine:
  519.             Err.Clear
  520.             Exit Sub
  521.             End Sub
  522.             
  523.             
  524.             
  525.             ' ******************************************************************************************************************************
  526.             ' * procedure name: InsertTransition
  527.             ' * procedure description: appends a transition to a timeline object
  528.             ' *
  529.             ' ******************************************************************************************************************************
  530.             Public Sub InsertTransition(objSourceTransition As AMTimelineTrans, objInsetDestination As AMTimelineObj, bstrEffectCLSID As String, dblTStart As Double, dblTStop As Double, Optional Priority As Long = -1)
  531.             Dim objTimelineObject As AMTimelineObj
  532.             Dim objTimelineTransable As IAMTimelineTransable
  533.             On Local Error GoTo ErrLine
  534.             
  535.             If ObjPtr(objSourceTransition) > 0 Then
  536.                If ObjPtr(objInsetDestination) > 0 Then
  537.                   'query for the timelineobj object
  538.                   Set objTimelineObject = objSourceTransition
  539.                   Call objTimelineObject.SetSubObjectGUIDB(bstrEffectCLSID)
  540.                   Call objTimelineObject.SetStartStop2(dblTStart, dblTStop)
  541.                   'insert the transition into the destination
  542.                   Set objTimelineTransable = objInsetDestination
  543.                   Call objTimelineTransable.TransAdd(objTimelineObject)
  544.                   'clean-up & dereference
  545.                   If ObjPtr(objTimelineObject) > 0 Then Set objTimelineObject = Nothing
  546.                   If ObjPtr(objTimelineTransable) > 0 Then Set objTimelineTransable = Nothing
  547.                End If
  548.             End If
  549.             Exit Sub
  550.             
  551. ErrLine:
  552.             Err.Clear
  553.             Exit Sub
  554.             End Sub
  555.             
  556.             
  557.             
  558.             ' ******************************************************************************************************************************
  559.             ' * procedure name: EngineFromTimeline
  560.             ' * procedure description: renders the timeline for the client
  561.             ' *
  562.             ' ******************************************************************************************************************************
  563.             Public Function EngineFromTimeline(objTimeline As AMTimeline) As RenderEngine
  564.             Dim objRenderEngine As RenderEngine
  565.             On Local Error GoTo ErrLine
  566.             
  567.             'instantiate new render engine
  568.             Set objRenderEngine = New RenderEngine
  569.             
  570.             'connect everything up..
  571.             Call objRenderEngine.SetTimelineObject(objTimeline)
  572.             objRenderEngine.ConnectFrontEnd
  573.             objRenderEngine.RenderOutputPins
  574.             
  575.             'return the render engine to the client
  576.             Set EngineFromTimeline = objRenderEngine
  577.             
  578.             'dereference & clean-up
  579.             If ObjPtr(objRenderEngine) > 0 Then Set objRenderEngine = Nothing
  580.             Exit Function
  581.             
  582. ErrLine:
  583.  
  584.             Err.Clear
  585.             Exit Function
  586.             End Function
  587.             
  588.             
  589.             ' ******************************************************************************************************************************
  590.             ' * procedure name: GraphFromTimeline
  591.             ' * procedure description: returns a graph from the given timeline
  592.             ' *
  593.             ' ******************************************************************************************************************************
  594.             Public Function GraphFromTimeline(objTimeline As AMTimeline) As IGraphBuilder
  595.             Dim objGraphBuilder As IGraphBuilder
  596.             Dim objRenderEngine As RenderEngine
  597.             On Local Error GoTo ErrLine
  598.             
  599.             'instantiate new render engine
  600.             Set objRenderEngine = New RenderEngine
  601.             
  602.             'connect everything up..
  603.             Call objRenderEngine.SetTimelineObject(objTimeline)
  604.             objRenderEngine.ConnectFrontEnd
  605.             objRenderEngine.RenderOutputPins
  606.             
  607.             'return the graph builder to the client
  608.             Call objRenderEngine.GetFilterGraph(objGraphBuilder)
  609.             If ObjPtr(objGraphBuilder) > 0 Then Set GraphFromTimeline = objGraphBuilder
  610.             
  611.             'dereference & clean-up
  612.             If ObjPtr(objGraphBuilder) > 0 Then Set objGraphBuilder = Nothing
  613.             If ObjPtr(objRenderEngine) > 0 Then Set objRenderEngine = Nothing
  614.             Exit Function
  615.             
  616. ErrLine:
  617.             Err.Clear
  618.             Exit Function
  619.             End Function
  620.             
  621.             
  622.             ' ******************************************************************************************************************************
  623.             ' * procedure name: RunFilterGraphSync
  624.             ' * procedure description: playsback the filtergraph for the client synchronously, and returns.
  625.             ' *
  626.             ' ******************************************************************************************************************************
  627.             Public Sub RunFilterGraphSync(objGraph As IFilterGraph)
  628.             Dim nExitCode As Long
  629.             Dim objMediaEvent As IMediaEvent
  630.             Dim objMediaControl As IMediaControl
  631.             On Local Error GoTo ErrLine
  632.             
  633.             'obtain the media control, event
  634.             Set objMediaEvent = objGraph
  635.             Set objMediaControl = objGraph
  636.             
  637.             'render the graph
  638.             objMediaControl.Run
  639.             'wait for play to complete..
  640.             objMediaEvent.WaitForCompletion -1, nExitCode
  641.             
  642.             'clean-up & dereference
  643.             If ObjPtr(objMediaEvent) > 0 Then Set objMediaEvent = Nothing
  644.             If ObjPtr(objMediaControl) > 0 Then Set objMediaControl = Nothing
  645.             Exit Sub
  646.             
  647. ErrLine:
  648.             Err.Clear
  649.             Exit Sub
  650.             End Sub
  651.             
  652.             
  653.            
  654.             
  655.             ' ******************************************************************************************************************************
  656.             ' * procedure name: TransitionCLSIDToFriendlyName
  657.             ' * procedure description: returns the localized friendly name of a transition given it's CLSID
  658.             ' *
  659.             ' ******************************************************************************************************************************
  660.              Public Function TransitionCLSIDToFriendlyName(bstrTransitionCLSID As String, Optional bstrLanguage As String = "EN-US") As String
  661.              Dim bstrReturn As String
  662.              On Local Error GoTo ErrLine
  663.              
  664.              If UCase(bstrLanguage) = "EN-US" Then
  665.                          Select Case bstrTransitionCLSID
  666.                             Case "{C3BDF740-0B58-11d2-A484-00C04F8EFB69}"
  667.                                 bstrReturn = "Barn"
  668.                             Case "{00C429C0-0BA9-11d2-A484-00C04F8EFB69}"
  669.                                 bstrReturn = "Blinds"
  670.                             Case "{107045D1-06E0-11D2-8D6D-00C04F8EF8E0}"
  671.                                 bstrReturn = "BurnFilm"
  672.                             Case "{AA0D4D0C-06A3-11D2-8F98-00C04FB92EB7}"
  673.                                 bstrReturn = "CenterCurls"
  674.                             Case "{2A54C908-07AA-11D2-8D6D-00C04F8EF8E0}"
  675.                                 bstrReturn = "ColorFade"
  676.                             Case "{9A43A844-0831-11D1-817F-0000F87557DB}"
  677.                                 bstrReturn = "Compositor"
  678.                             Case "{AA0D4D0E-06A3-11D2-8F98-00C04FB92EB7}"
  679.                                 bstrReturn = "Curls"
  680.                             Case "{AA0D4D12-06A3-11D2-8F98-00C04FB92EB7}"
  681.                                 bstrReturn = "Curtains"
  682.                             Case "{16B280C5-EE70-11D1-9066-00C04FD9189D}"
  683.                                 bstrReturn = "Fade"
  684.                             Case "{107045CC-06E0-11D2-8D6D-00C04F8EF8E0}"
  685.                                 bstrReturn = "FadeWhite"
  686.                             Case "{2A54C90B-07AA-11D2-8D6D-00C04F8EF8E0}"
  687.                                 bstrReturn = "FlowMotion"
  688.                             Case "{2A54C913-07AA-11D2-8D6D-00C04F8EF8E0}"
  689.                                 bstrReturn = "GlassBlock"
  690.                             Case "{2A54C911-07AA-11D2-8D6D-00C04F8EF8E0}"
  691.                                 bstrReturn = "Grid"
  692.                             Case "{93073C40-0BA5-11d2-A484-00C04F8EFB69}"
  693.                                 bstrReturn = "Inset"
  694.                             Case "{3F69F351-0379-11D2-A484-00C04F8EFB69}"
  695.                                 bstrReturn = "Iris"
  696.                             Case "{2A54C904-07AA-11D2-8D6D-00C04F8EF8E0}"
  697.                                 bstrReturn = "Jaws"
  698.                             Case "{107045CA-06E0-11D2-8D6D-00C04F8EF8E0}"
  699.                                 bstrReturn = "Lens"
  700.                             Case "{107045C8-06E0-11D2-8D6D-00C04F8EF8E0}"
  701.                                 bstrReturn = "LightWipe"
  702.                             Case "{AA0D4D0A-06A3-11D2-8F98-00C04FB92EB7}"
  703.                                 bstrReturn = "Liquid"
  704.                             Case "{AA0D4D08-06A3-11D2-8F98-00C04FB92EB7}"
  705.                                 bstrReturn = "PageCurl"
  706.                             Case "{AA0D4D10-06A3-11D2-8F98-00C04FB92EB7}"
  707.                                 bstrReturn = "PeelABCD"
  708.                             Case "{4CCEA634-FBE0-11d1-906A-00C04FD9189D}"
  709.                                 bstrReturn = "Pixelate"
  710.                             Case "{424B71AF-0695-11D2-A484-00C04F8EFB69}"
  711.                                 bstrReturn = "RadialWipe"
  712.                             Case "{AA0D4D03-06A3-11D2-8F98-00C04FB92EB7}"
  713.                                 bstrReturn = "Ripple"
  714.                             Case "{9C61F46E-0530-11D2-8F98-00C04FB92EB7}"
  715.                                 bstrReturn = "RollDown"
  716.                             Case "{810E402F-056B-11D2-A484-00C04F8EFB69}"
  717.                                 bstrReturn = "Slide"
  718.                             Case "{dE75D012-7A65-11D2-8CEA-00A0C9441E20}"
  719.                                 bstrReturn = "SMPTE Wipe"
  720.                             Case "{ACA97E00-0C7D-11d2-A484-00C04F8EFB69}"
  721.                                 bstrReturn = "Spiral"
  722.                             Case "{7658F2A2-0A83-11d2-A484-00C04F8EFB69}"
  723.                                 bstrReturn = "Stretch"
  724.                             Case "{2A54C915-07AA-11D2-8D6D-00C04F8EF8E0}"
  725.                                 bstrReturn = "Threshold"
  726.                             Case "{107045CF-06E0-11D2-8D6D-00C04F8EF8E0}"
  727.                                 bstrReturn = "Twister"
  728.                             Case "{2A54C90D-07AA-11D2-8D6D-00C04F8EF8E0}"
  729.                                 bstrReturn = "Vacuum"
  730.                             Case "{107045C5-06E0-11D2-8D6D-00C04F8EF8E0}"
  731.                                 bstrReturn = "Water"
  732.                             Case "{5AE1DAE0-1461-11d2-A484-00C04F8EFB69}"
  733.                                 bstrReturn = "Wheel"
  734.                             Case "{AF279B30-86EB-11D1-81BF-0000F87557DB}"
  735.                                 bstrReturn = "Wipe"
  736.                             Case "{0E6AE022-0C83-11D2-8CD4-00104BC75D9A}"
  737.                                 bstrReturn = "WormHole"
  738.                             Case "{E6E73D20-0C8A-11d2-A484-00C04F8EFB69}"
  739.                                 bstrReturn = "Zigzag"
  740.                             Case Else: bstrReturn = vbNullString
  741.                         End Select
  742.             End If
  743.             'return friendly name to the client
  744.             TransitionCLSIDToFriendlyName = bstrReturn
  745.             Exit Function
  746.             
  747. ErrLine:
  748.             Err.Clear
  749.             Exit Function
  750.             End Function
  751.              
  752.              
  753.              
  754.             ' ******************************************************************************************************************************
  755.             ' * procedure name: TransitionFriendlyNameToCLSID
  756.             ' * procedure description: returns the CLSID of a transition given it's localized friendly name
  757.             ' *
  758.             ' ******************************************************************************************************************************
  759.              Public Function TransitionFriendlyNameToCLSID(bstrFriendlyName As String, Optional bstrLanguage As String = "EN-US") As String
  760.              Dim bstrReturn As String
  761.              On Local Error GoTo ErrLine
  762.              
  763.              If UCase(bstrLanguage) = "EN-US" Then
  764.                         Select Case bstrFriendlyName
  765.                             Case "Barn"
  766.                                       bstrReturn = "{C3BDF740-0B58-11d2-A484-00C04F8EFB69}"
  767.                             Case "Blinds"
  768.                                       bstrReturn = "{00C429C0-0BA9-11d2-A484-00C04F8EFB69}"
  769.                             Case "BurnFilm"
  770.                                       bstrReturn = "{107045D1-06E0-11D2-8D6D-00C04F8EF8E0}"
  771.                             Case "CenterCurls"
  772.                                       bstrReturn = "{AA0D4D0C-06A3-11D2-8F98-00C04FB92EB7}"
  773.                             Case "ColorFade"
  774.                                       bstrReturn = "{2A54C908-07AA-11D2-8D6D-00C04F8EF8E0}"
  775.                             Case "Compositor"
  776.                                       bstrReturn = "{9A43A844-0831-11D1-817F-0000F87557DB}"
  777.                             Case "Curls"
  778.                                       bstrReturn = "{AA0D4D0E-06A3-11D2-8F98-00C04FB92EB7}"
  779.                             Case "Curtains"
  780.                                       bstrReturn = "{AA0D4D12-06A3-11D2-8F98-00C04FB92EB7}"
  781.                             Case "Fade"
  782.                                       bstrReturn = "{16B280C5-EE70-11D1-9066-00C04FD9189D}"
  783.                             Case "FadeWhite"
  784.                                       bstrReturn = "{107045CC-06E0-11D2-8D6D-00C04F8EF8E0}"
  785.                             Case "FlowMotion"
  786.                                       bstrReturn = "{2A54C90B-07AA-11D2-8D6D-00C04F8EF8E0}"
  787.                             Case "GlassBlock"
  788.                                       bstrReturn = "{2A54C913-07AA-11D2-8D6D-00C04F8EF8E0}"
  789.                             Case "Grid"
  790.                                       bstrReturn = "{2A54C911-07AA-11D2-8D6D-00C04F8EF8E0}"
  791.                             Case "Inset"
  792.                                       bstrReturn = "{93073C40-0BA5-11d2-A484-00C04F8EFB69}"
  793.                             Case "Iris"
  794.                                       bstrReturn = "{3F69F351-0379-11D2-A484-00C04F8EFB69}"
  795.                             Case "Jaws"
  796.                                       bstrReturn = "{2A54C904-07AA-11D2-8D6D-00C04F8EF8E0}"
  797.                             Case "Lens"
  798.                                       bstrReturn = "{107045CA-06E0-11D2-8D6D-00C04F8EF8E0}"
  799.                             Case "LightWipe"
  800.                                       bstrReturn = "{107045C8-06E0-11D2-8D6D-00C04F8EF8E0}"
  801.                             Case "Liquid"
  802.                                       bstrReturn = "{AA0D4D0A-06A3-11D2-8F98-00C04FB92EB7}"
  803.                             Case "PageCurl"
  804.                                       bstrReturn = "{AA0D4D08-06A3-11D2-8F98-00C04FB92EB7}"
  805.                             Case "PeelABCD"
  806.                                       bstrReturn = "{AA0D4D10-06A3-11D2-8F98-00C04FB92EB7}"
  807.                             Case "Pixelate"
  808.                                       bstrReturn = "{4CCEA634-FBE0-11d1-906A-00C04FD9189D}"
  809.                             Case "RadialWipe"
  810.                                       bstrReturn = "{424B71AF-0695-11D2-A484-00C04F8EFB69}"
  811.                             Case "Ripple"
  812.                                       bstrReturn = "{AA0D4D03-06A3-11D2-8F98-00C04FB92EB7}"
  813.                             Case "RollDown"
  814.                                       bstrReturn = "{9C61F46E-0530-11D2-8F98-00C04FB92EB7}"
  815.                             Case "Slide"
  816.                                       bstrReturn = "{810E402F-056B-11D2-A484-00C04F8EFB69}"
  817.                             Case "SMPTE Wipe"
  818.                                       bstrReturn = "{dE75D012-7A65-11D2-8CEA-00A0C9441E20}"
  819.                             Case "Spiral"
  820.                                       bstrReturn = "{ACA97E00-0C7D-11d2-A484-00C04F8EFB69}"
  821.                             Case "Stretch"
  822.                                       bstrReturn = "{7658F2A2-0A83-11d2-A484-00C04F8EFB69}"
  823.                             Case "Threshold"
  824.                                       bstrReturn = "{2A54C915-07AA-11D2-8D6D-00C04F8EF8E0}"
  825.                             Case "Twister"
  826.                                       bstrReturn = "{107045CF-06E0-11D2-8D6D-00C04F8EF8E0}"
  827.                             Case "Vacuum"
  828.                                       bstrReturn = "{2A54C90D-07AA-11D2-8D6D-00C04F8EF8E0}"
  829.                             Case "Water"
  830.                                       bstrReturn = "{107045C5-06E0-11D2-8D6D-00C04F8EF8E0}"
  831.                             Case "Wheel"
  832.                                       bstrReturn = "{5AE1DAE0-1461-11d2-A484-00C04F8EFB69}"
  833.                             Case "Wipe"
  834.                                       bstrReturn = "{AF279B30-86EB-11D1-81BF-0000F87557DB}"
  835.                             Case "WormHole"
  836.                                       bstrReturn = "{0E6AE022-0C83-11D2-8CD4-00104BC75D9A}"
  837.                             Case "Zigzag"
  838.                                       bstrReturn = "{E6E73D20-0C8A-11d2-A484-00C04F8EFB69}"
  839.                             Case Else: bstrReturn = vbNullString
  840.                         End Select
  841.             End If
  842.             'return friendly name to the client
  843.             TransitionFriendlyNameToCLSID = bstrReturn
  844.             Exit Function
  845.             
  846. ErrLine:
  847.             Err.Clear
  848.             Exit Function
  849.             End Function
  850.             
  851.             
  852.             
  853.             ' ******************************************************************************************************************************
  854.             ' * procedure name: EffectCLSIDToFriendlyName
  855.             ' * procedure description: returns the localized friendly name of an effect given it's CLSID
  856.             ' *
  857.             ' ******************************************************************************************************************************
  858.              Public Function EffectCLSIDToFriendlyName(bstrTransitionCLSID As String, Optional bstrLanguage As String = "EN-US") As String
  859.              Dim bstrReturn As String
  860.              On Local Error GoTo ErrLine
  861.              
  862.              If UCase(bstrLanguage) = "EN-US" Then
  863.                          Select Case bstrTransitionCLSID
  864.                             Case "{16B280C8-EE70-11D1-9066-00C04FD9189D}"
  865.                                      bstrReturn = "BasicImage"
  866.                             Case "{7312498D-E87A-11d1-81E0-0000F87557DB}"
  867.                                      bstrReturn = "Blur"
  868.                             Case "{421516C1-3CF8-11D2-952A-00C04FA34F05}"
  869.                                      bstrReturn = "Chroma"
  870.                             Case "{ADC6CB86-424C-11D2-952A-00C04FA34F05}"
  871.                                      bstrReturn = "DropShadow"
  872.                             Case "{F515306D-0156-11d2-81EA-0000F87557DB}"
  873.                                      bstrReturn = "Emboss"
  874.                             Case "{F515306E-0156-11d2-81EA-0000F87557DB}"
  875.                                      bstrReturn = "Engrave"
  876.                             Case "{16B280C5-EE70-11D1-9066-00C04FD9189D}"
  877.                                      bstrReturn = "Fade"
  878.                             Case "{4CCEA634-FBE0-11d1-906A-00C04FD9189D}"
  879.                                      bstrReturn = "Pixelate"
  880.                             Case Else: bstrReturn = vbNullString
  881.                         End Select
  882.             End If
  883.             'return friendly name to the client
  884.             EffectCLSIDToFriendlyName = bstrReturn
  885.             Exit Function
  886.             
  887. ErrLine:
  888.             Err.Clear
  889.             Exit Function
  890.             End Function
  891.              
  892.               
  893.               
  894.             ' ******************************************************************************************************************************
  895.             ' * procedure name: EffectFriendlyNameToCLSID
  896.             ' * procedure description: returns the CLSID of an effect given it's localized friendly name
  897.             ' *
  898.             ' ******************************************************************************************************************************
  899.              Public Function EffectFriendlyNameToCLSID(bstrFriendlyName As String, Optional bstrLanguage As String = "EN-US") As String
  900.              Dim bstrReturn As String
  901.              On Local Error GoTo ErrLine
  902.              
  903.              If UCase(bstrLanguage) = "EN-US" Then
  904.                         Select Case bstrFriendlyName
  905.                             Case "BasicImage"
  906.                                      bstrReturn = "{16B280C8-EE70-11D1-9066-00C04FD9189D}"
  907.                             Case "Blur"
  908.                                      bstrReturn = "{7312498D-E87A-11d1-81E0-0000F87557DB}"
  909.                             Case "Chroma"
  910.                                      bstrReturn = "{421516C1-3CF8-11D2-952A-00C04FA34F05}"
  911.                             Case "DropShadow"
  912.                                      bstrReturn = "{ADC6CB86-424C-11D2-952A-00C04FA34F05}"
  913.                             Case "Emboss"
  914.                                      bstrReturn = "{F515306D-0156-11d2-81EA-0000F87557DB}"
  915.                             Case "Engrave"
  916.                                      bstrReturn = "{F515306E-0156-11d2-81EA-0000F87557DB}"
  917.                             Case "Fade"
  918.                                      bstrReturn = "{16B280C5-EE70-11D1-9066-00C04FD9189D}"
  919.                             Case "Pixelate"
  920.                                      bstrReturn = "{4CCEA634-FBE0-11d1-906A-00C04FD9189D}"
  921.                             Case Else: bstrReturn = vbNullString
  922.                         End Select
  923.             End If
  924.             'return friendly name to the client
  925.             EffectFriendlyNameToCLSID = bstrReturn
  926.             Exit Function
  927.             
  928. ErrLine:
  929.             Err.Clear
  930.             Exit Function
  931.             End Function
  932.             
  933.             
  934.             
  935.             ' ******************************************************************************************************************************
  936.             ' * procedure name: GetGroupCount
  937.             ' * procedure description: returns the number of groups encapsulated within the given timeline
  938.             ' *
  939.             ' ******************************************************************************************************************************
  940.             Public Function GetGroupCount(objTimeline As AMTimeline) As Long
  941.             Dim nCount As Long
  942.             On Local Error GoTo ErrLine
  943.              
  944.             'obtain the number of groups
  945.             Call objTimeline.GetGroupCount(nCount)
  946.             'return the group count
  947.             GetGroupCount = nCount
  948.             Exit Function
  949.             
  950. ErrLine:
  951.             Err.Clear
  952.             Exit Function
  953.             End Function
  954.             
  955.             
  956.             
  957.             ' ******************************************************************************************************************************
  958.             ' * procedure name: HasGroups
  959.             ' * procedure description: returns a boolean indicating wether or not the specified timeline has any any groups inserted
  960.             ' *
  961.             ' ******************************************************************************************************************************
  962.             Public Function HasGroups(objTimeline As AMTimeline) As Boolean
  963.             Dim nCount As Long
  964.             On Local Error GoTo ErrLine
  965.              
  966.             'obtain the number of groups
  967.             Call objTimeline.GetGroupCount(nCount)
  968.             'return the group count
  969.             If nCount > 0 Then HasGroups = True
  970.             Exit Function
  971.             
  972. ErrLine:
  973.             Err.Clear
  974.             Exit Function
  975.             End Function
  976.             
  977.             
  978.             
  979.             ' ******************************************************************************************************************************
  980.             ' * procedure name: HasStreams
  981.             ' * procedure description:  Returns True if the given media file contains any valid streams at all
  982.             ' *
  983.             ' ******************************************************************************************************************************
  984.             Public Function HasStreams(bstrFileName As String) As Boolean
  985.             Dim nStreams As Long
  986.             Dim objMediaDet As MediaDet
  987.             On Local Error GoTo ErrLine
  988.             
  989.             'verify argument(s)
  990.             If bstrFileName <> vbNullString Then
  991.                'instantiate mediadet
  992.                Set objMediaDet = New MediaDet
  993.                'assign the filename to the MediaDet
  994.                objMediaDet.FileName = bstrFileName
  995.                'obtain the number of streams
  996.                nStreams = objMediaDet.OutputStreams
  997.                'verify there is at least one valid media stream in the assigned file
  998.                If nStreams > 0 Then HasStreams = True
  999.             End If
  1000.             
  1001.             'clean-up & dereference
  1002.             If ObjPtr(objMediaDet) > 0 Then Set objMediaDet = Nothing
  1003.             Exit Function
  1004.             
  1005. ErrLine:
  1006.  
  1007.             Err.Clear
  1008.             Exit Function
  1009.             End Function
  1010.             
  1011.             
  1012.             ' ******************************************************************************************************************************
  1013.             ' * procedure name: HasVideoStream
  1014.             ' * procedure description:  Returns True if the given media file contains a valid video stream
  1015.             ' *
  1016.             ' ******************************************************************************************************************************
  1017.             Public Function HasVideoStream(bstrFileName As String) As Boolean
  1018.             Dim nCount As Long
  1019.             Dim nStreams As Long
  1020.             Dim objMediaDet As MediaDet
  1021.             Dim bstrMediaCLSID As String
  1022.             On Local Error GoTo ErrLine
  1023.             
  1024.             'verify argument(s)
  1025.             If bstrFileName <> vbNullString Then
  1026.                'instantiate mediadet
  1027.                Set objMediaDet = New MediaDet
  1028.                'assign the filename to the MediaDet
  1029.                objMediaDet.FileName = bstrFileName
  1030.                'obtain the number of streams
  1031.                nStreams = objMediaDet.OutputStreams
  1032.                'verify there is at least one valid media stream in the assigned file
  1033.                If nStreams > 0 Then
  1034.                   For nCount = 0 To objMediaDet.OutputStreams - 1
  1035.                        objMediaDet.CurrentStream = nCount
  1036.                        bstrMediaCLSID = objMediaDet.StreamTypeB
  1037.                        If bstrMediaCLSID = SLIDESHOWVB_VIDEOTYPE Then
  1038.                           HasVideoStream = True: Exit For
  1039.                        End If
  1040.                   Next
  1041.                End If
  1042.             End If
  1043.             
  1044.             'clean-up & dereference
  1045.             If ObjPtr(objMediaDet) > 0 Then Set objMediaDet = Nothing
  1046.             Exit Function
  1047.             
  1048. ErrLine:
  1049.  
  1050.             Err.Clear
  1051.             Exit Function
  1052.             End Function
  1053.             
  1054.             
  1055.             
  1056.             ' ******************************************************************************************************************************
  1057.             ' * procedure name: HasAudioStream
  1058.             ' * procedure description:  Returns True if the given media file contains a valid audio stream
  1059.             ' *
  1060.             ' ******************************************************************************************************************************
  1061.             Public Function HasAudioStream(bstrFileName As String) As Boolean
  1062.             Dim nCount As Long
  1063.             Dim nStreams As Long
  1064.             Dim objMediaDet As MediaDet
  1065.             Dim bstrMediaCLSID As String
  1066.             On Local Error GoTo ErrLine
  1067.             
  1068.             'verify argument(s)
  1069.             If bstrFileName <> vbNullString Then
  1070.                'instantiate mediadet
  1071.                Set objMediaDet = New MediaDet
  1072.                'assign the filename to the MediaDet
  1073.                objMediaDet.FileName = bstrFileName
  1074.                'obtain the number of streams
  1075.                nStreams = objMediaDet.OutputStreams
  1076.                'verify there is at least one valid media stream in the assigned file
  1077.                If nStreams > 0 Then
  1078.                   For nCount = 0 To objMediaDet.OutputStreams - 1
  1079.                        objMediaDet.CurrentStream = nCount
  1080.                        bstrMediaCLSID = objMediaDet.StreamTypeB
  1081.                        If bstrMediaCLSID = SLIDESHOWVB_AUDIOTYPE Then
  1082.                           HasAudioStream = True: Exit For
  1083.                        End If
  1084.                   Next
  1085.                End If
  1086.             End If
  1087.             
  1088.             'clean-up & dereference
  1089.             If ObjPtr(objMediaDet) > 0 Then Set objMediaDet = Nothing
  1090.             Exit Function
  1091.             
  1092. ErrLine:
  1093.  
  1094.             Err.Clear
  1095.             Exit Function
  1096.             End Function
  1097.             
  1098.             
  1099.             
  1100.             
  1101. ' **************************************************************************************************************************************
  1102. ' * PUBLIC INTERFACE- QUARTZ PROCEDURES
  1103. ' *
  1104. ' *
  1105.             ' ******************************************************************************************************************************
  1106.             ' * procedure name: RenderTimeline
  1107.             ' * procedure description: renders the timeline for the client and returns an instance of the filter graph manager
  1108.             ' *                                      NOTE:  THIS PROCEDURE USES MODULE-LEVEL VARIABLES BECAUSE
  1109.             ' *                                                   IT WORKS ASYNCRONOUSLY.  IF YOU MOVE THEM OVER LOCALLY
  1110.             ' *                                                   YOUR APPLICATION WILL TAKE A READ FAULT BECAUSE QEDIT WILL
  1111.             ' *                                                   NOT BE ABLE TO READ YOUR FILTERGRAPH WHEN THE PROCEDURE EXITS.
  1112.             ' ******************************************************************************************************************************
  1113.             Public Function RenderTimeline(objTimeline As AMTimeline, Optional UseDynamicConnections As Boolean, Optional UseSmartRecompression As Boolean) As FilgraphManager
  1114.             On Local Error GoTo ErrLine
  1115.             
  1116.             'instantiate new render engine
  1117.             Set m_objRenderEngine = New RenderEngine
  1118.             
  1119.             'setup dynamic connections
  1120.             If UseDynamicConnections = True Then
  1121.                Call m_objRenderEngine.SetDynamicReconnectLevel(1)
  1122.             Else: Call m_objRenderEngine.SetDynamicReconnectLevel(0)
  1123.             End If
  1124.             
  1125.             'setup smart recompression
  1126.             If UseSmartRecompression = True Then
  1127.                'smart recompression is not currently supported in vb
  1128.             End If
  1129.             
  1130.             'connect everything up..
  1131.             Call m_objRenderEngine.SetTimelineObject(objTimeline)
  1132.             m_objRenderEngine.ConnectFrontEnd
  1133.             m_objRenderEngine.RenderOutputPins
  1134.             
  1135.             'render the audio/video
  1136.             Call m_objRenderEngine.GetFilterGraph(m_objFilterGraph)
  1137.             Set m_objFilterGraphManager = New FilgraphManager
  1138.             Set m_objFilterGraphManager = m_objFilterGraph
  1139.             
  1140.             'return an instance of the filgraph manager to the client
  1141.             Set RenderTimeline = m_objFilterGraphManager
  1142.             Exit Function
  1143.             
  1144. ErrLine:
  1145.  
  1146.             Err.Clear
  1147.             Exit Function
  1148.             End Function
  1149.             
  1150.             
  1151.             ' ******************************************************************************************************************************
  1152.             ' * procedure name: RenderTimelineSync
  1153.             ' * procedure description: Renders the timeline for the client, and waits for completion
  1154.             ' *                                      until the media completes or until the specified timeout is reached..
  1155.             ' *
  1156.             ' ******************************************************************************************************************************
  1157.             Public Sub RenderTimelineSync(objTimeline As AMTimeline, Optional Timeout As Long = -1)
  1158.             Dim nExitCode As Long
  1159.             Dim objMediaEvent As IMediaEvent
  1160.             Dim objMediaControl As IMediaControl
  1161.             Dim objFilterGraph As IGraphBuilder
  1162.             Dim objRenderEngine As RenderEngine
  1163.             On Local Error GoTo ErrLine
  1164.             
  1165.             'instantiate new render engine
  1166.             Set objRenderEngine = New RenderEngine
  1167.             
  1168.             'connect everything up..
  1169.             Call objRenderEngine.SetTimelineObject(objTimeline)
  1170.             objRenderEngine.ConnectFrontEnd
  1171.             objRenderEngine.RenderOutputPins
  1172.             
  1173.             'obtain the filtergraph
  1174.             Call objRenderEngine.GetFilterGraph(objFilterGraph)
  1175.             Set objMediaEvent = objFilterGraph
  1176.             Set objMediaControl = objFilterGraph
  1177.             
  1178.             'render the graph
  1179.             objMediaControl.Run
  1180.             'wait for the graph to complete..
  1181.             objMediaEvent.WaitForCompletion Timeout, nExitCode
  1182.             
  1183.             'clean-up & dereference
  1184.             If ObjPtr(objFilterGraph) > 0 Then Set objFilterGraph = Nothing
  1185.             If ObjPtr(objMediaEvent) > 0 Then Set objMediaEvent = Nothing
  1186.             If ObjPtr(objMediaControl) > 0 Then Set objMediaControl = Nothing
  1187.             If ObjPtr(objRenderEngine) > 0 Then Set objRenderEngine = Nothing
  1188.             Exit Sub
  1189.             
  1190. ErrLine:
  1191.             Err.Clear
  1192.             Exit Sub
  1193.             End Sub
  1194.             
  1195.             
  1196.             ' ******************************************************************************************************************************
  1197.             ' * procedure name: RenderTimelineAsync
  1198.             ' * procedure description: renders the timeline for the client in true async fashion
  1199.             ' *                                      NOTE:  THIS PROCEDURE USES MODULE-LEVEL VARIABLES BECAUSE
  1200.             ' *                                                   IT WORKS ASYNCRONOUSLY.  IF YOU MOVE THEM OVER LOCALLY
  1201.             ' *                                                   YOUR APPLICATION WILL TAKE A READ FAULT BECAUSE QEDIT WILL
  1202.             ' *                                                   NOT BE ABLE TO READ YOUR FILTERGRAPH WHEN THE PROCEDURE EXITS.
  1203.             ' ******************************************************************************************************************************
  1204.             Public Sub RenderTimelineAsync(objTimeline As AMTimeline)
  1205.             On Local Error GoTo ErrLine
  1206.             
  1207.             'instantiate new render engine
  1208.             Set gbl_objRenderEngine = New RenderEngine
  1209.             
  1210.             'connect everything up..
  1211.             Call gbl_objRenderEngine.SetTimelineObject(objTimeline)
  1212.             gbl_objRenderEngine.ConnectFrontEnd
  1213.             gbl_objRenderEngine.RenderOutputPins
  1214.             
  1215.             'render the audio/video
  1216.             Call gbl_objRenderEngine.GetFilterGraph(m_objFilterGraph)
  1217.             Set m_objFilterGraphManager = New FilgraphManager
  1218.             Set m_objFilterGraphManager = m_objFilterGraph
  1219.             m_objFilterGraphManager.Run
  1220.             Exit Sub
  1221.             
  1222. ErrLine:
  1223.  
  1224.             Err.Clear
  1225.             Exit Sub
  1226.             End Sub
  1227.             
  1228.             
  1229.             
  1230.             ' ******************************************************************************************************************************
  1231.             ' * procedure name: RenderTimelineQuasiAsync
  1232.             ' * procedure description: Renders the timeline for the client, and waits for completion by using
  1233.             ' *                                      a structured loop which constantly checks for EC_COMPLETE to occur.
  1234.             ' *                                      By using the VB 'WithEvents' Keyword normal form events are uninhibited.
  1235.             ' *                                      as VB will basically handle the multi-threading for you.
  1236.             ' *                                      To Stop playback use recursion with syntax: Call RenderTimelineQuasiAsync(Nothing)
  1237.             ' ******************************************************************************************************************************
  1238.             Public Sub RenderTimelineQuasiAsync(objTimeline As AMTimeline)
  1239.             Static nResultant As Long
  1240.             Static objPosition As IMediaPosition
  1241.             Static objMediaEvent As IMediaEvent
  1242.             Static objFilterGraph As IGraphBuilder
  1243.             Static objVideoWindow As IVideoWindow
  1244.             Static objRenderEngine As RenderEngine
  1245.             Static objFilterGraphManager As New FilgraphManager
  1246.             On Local Error GoTo ErrLine
  1247.             
  1248.             If ObjPtr(objTimeline) > 0 Then
  1249.                'instantiate new render engine
  1250.                Set objRenderEngine = New RenderEngine
  1251.                
  1252.                'connect everything up..
  1253.                Call objRenderEngine.SetTimelineObject(objTimeline)
  1254.                objRenderEngine.ConnectFrontEnd
  1255.                objRenderEngine.RenderOutputPins
  1256.                
  1257.                'render the audio/video
  1258.                Call objRenderEngine.GetFilterGraph(objFilterGraph)
  1259.                Set objFilterGraphManager = New FilgraphManager
  1260.                Set objFilterGraphManager = objFilterGraph
  1261.                objFilterGraphManager.Run
  1262.                'obtain the position of audio/video
  1263.                Set objPosition = objFilterGraphManager
  1264.                'obtain the video window
  1265.                Set objMediaEvent = objFilterGraphManager
  1266.                Set objVideoWindow = objMediaEvent
  1267.                
  1268.                'loop with events until the media has finished or the video
  1269.                'window has been manually closed (if the timeline has video)
  1270.                Do: DoEvents
  1271.                      'check state
  1272.                      If ObjPtr(objMediaEvent) > 0 Then _
  1273.                         Call objMediaEvent.WaitForCompletion(10, nResultant)
  1274.                      'evaluate resultant
  1275.                      If nResultant = 1 Then  'EC_COMPLETE
  1276.                         If ObjPtr(objVideoWindow) > 0 Then
  1277.                            objVideoWindow.Left = Screen.Width * 8
  1278.                            objVideoWindow.Top = Screen.Height * 8
  1279.                            objVideoWindow.Visible = False
  1280.                         End If
  1281.                         If ObjPtr(objFilterGraphManager) > 0 Then _
  1282.                            Call objFilterGraphManager.Stop
  1283.                         Exit Do
  1284.                      ElseIf objVideoWindow.Visible = False Then
  1285.                         If ObjPtr(objFilterGraphManager) > 0 Then _
  1286.                            Call objFilterGraphManager.Stop
  1287.                         Exit Do
  1288.                      ElseIf ObjPtr(objTimeline) = 0 Then
  1289.                         Exit Do
  1290.                      ElseIf ObjPtr(objFilterGraphManager) = 0 Then
  1291.                         Exit Do
  1292.                      End If
  1293.                Loop
  1294.             Else: nResultant = 1
  1295.             End If
  1296.             
  1297.             'clean-up & dereference
  1298.             If ObjPtr(objPosition) > 0 Then Set objPosition = Nothing
  1299.             If ObjPtr(objFilterGraph) > 0 Then Set objFilterGraph = Nothing
  1300.             If ObjPtr(objMediaEvent) > 0 Then Set objMediaEvent = Nothing
  1301.             If ObjPtr(objVideoWindow) > 0 Then Set objVideoWindow = Nothing
  1302.             If ObjPtr(objRenderEngine) > 0 Then Set objRenderEngine = Nothing
  1303.             If ObjPtr(objFilterGraphManager) > 0 Then Set objFilterGraphManager = Nothing
  1304.             Exit Sub
  1305.             
  1306. ErrLine:
  1307.             Err.Clear
  1308.             Resume Next
  1309.             Exit Sub
  1310.             End Sub
  1311.