home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / DirectX8 / dx8vbsdk.exe / samples / multimedia / vbsamples / directshow / editing / trimmervb / frmmain.frm (.txt) next >
Encoding:
Visual Basic Form  |  2000-09-22  |  51.2 KB  |  1,217 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form frmMain 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "TrimmerVB"
  7.    ClientHeight    =   8775
  8.    ClientLeft      =   60
  9.    ClientTop       =   345
  10.    ClientWidth     =   10890
  11.    Icon            =   "frmMain.frx":0000
  12.    LinkTopic       =   "frmMain"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   8775
  15.    ScaleWidth      =   10890
  16.    StartUpPosition =   2  'CenterScreen
  17.    Begin VB.TextBox txtInstruction 
  18.       Appearance      =   0  'Flat
  19.       BackColor       =   &H8000000F&
  20.       BorderStyle     =   0  'None
  21.       Height          =   1365
  22.       HideSelection   =   0   'False
  23.       Left            =   7425
  24.       Locked          =   -1  'True
  25.       MultiLine       =   -1  'True
  26.       TabIndex        =   40
  27.       TabStop         =   0   'False
  28.       Text            =   "frmMain.frx":030A
  29.       Top             =   4875
  30.       Width           =   3315
  31.    End
  32.    Begin VB.Frame fraPretty 
  33.       Enabled         =   0   'False
  34.       Height          =   4815
  35.       Left            =   7305
  36.       TabIndex        =   38
  37.       Top             =   3525
  38.       Width           =   3540
  39.       Begin VB.Timer tmrTimer 
  40.          Interval        =   1000
  41.          Left            =   600
  42.          Top             =   4330
  43.       End
  44.       Begin VB.TextBox txtCopyright 
  45.          Appearance      =   0  'Flat
  46.          BackColor       =   &H8000000F&
  47.          BorderStyle     =   0  'None
  48.          Height          =   840
  49.          Left            =   975
  50.          Locked          =   -1  'True
  51.          MultiLine       =   -1  'True
  52.          TabIndex        =   39
  53.          TabStop         =   0   'False
  54.          Text            =   "frmMain.frx":03D5
  55.          Top             =   225
  56.          Width           =   2490
  57.       End
  58.       Begin MSComDlg.CommonDialog ctrlCommonDialog 
  59.          Left            =   75
  60.          Top             =   4275
  61.          _ExtentX        =   847
  62.          _ExtentY        =   847
  63.          _Version        =   393216
  64.       End
  65.       Begin VB.Line lnAboutSeptum 
  66.          X1              =   150
  67.          X2              =   3375
  68.          Y1              =   1125
  69.          Y2              =   1125
  70.       End
  71.       Begin VB.Image imgAbout 
  72.          Height          =   765
  73.          Left            =   150
  74.          Picture         =   "frmMain.frx":0454
  75.          Stretch         =   -1  'True
  76.          Top             =   225
  77.          Width           =   765
  78.       End
  79.    End
  80.    Begin MSComctlLib.StatusBar ctrlStatusBar 
  81.       Align           =   2  'Align Bottom
  82.       Height          =   390
  83.       Left            =   0
  84.       TabIndex        =   30
  85.       Top             =   8385
  86.       Width           =   10890
  87.       _ExtentX        =   19209
  88.       _ExtentY        =   688
  89.       Style           =   1
  90.       _Version        =   393216
  91.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  92.       EndProperty
  93.    End
  94.    Begin VB.Frame fraPreviewControl 
  95.       Caption         =   "Video Preview:"
  96.       Height          =   2340
  97.       Left            =   45
  98.       TabIndex        =   25
  99.       Top             =   6000
  100.       Width           =   7190
  101.       Begin VB.CommandButton cmdSetStop 
  102.          Caption         =   "Set Trim Preview Stop Position"
  103.          Height          =   375
  104.          Left            =   150
  105.          TabIndex        =   9
  106.          ToolTipText     =   "Selects the ending point of the trim operation."
  107.          Top             =   1755
  108.          Width           =   3000
  109.       End
  110.       Begin VB.CommandButton cmdSelStart 
  111.          Caption         =   "Set Trim Preview Start Position"
  112.          Height          =   375
  113.          Left            =   150
  114.          TabIndex        =   8
  115.          ToolTipText     =   "Selects the starting point of the trim operation."
  116.          Top             =   1275
  117.          Width           =   3000
  118.       End
  119.       Begin VB.Frame fraVideoPreview 
  120.          Height          =   940
  121.          Left            =   3300
  122.          TabIndex        =   31
  123.          Top             =   1200
  124.          Width           =   3765
  125.          Begin VB.Label lblFPS 
  126.             Caption         =   "FPS:"
  127.             Height          =   255
  128.             Left            =   150
  129.             TabIndex        =   37
  130.             Top             =   300
  131.             Width           =   975
  132.          End
  133.          Begin VB.Label lblFPSValue 
  134.             Caption         =   "0"
  135.             Height          =   255
  136.             Left            =   1230
  137.             TabIndex        =   36
  138.             Top             =   300
  139.             Width           =   1005
  140.          End
  141.          Begin VB.Label lblStreams 
  142.             Caption         =   "Streams:"
  143.             Height          =   255
  144.             Left            =   150
  145.             TabIndex        =   35
  146.             Top             =   540
  147.             Width           =   975
  148.          End
  149.          Begin VB.Label lblStreamsValue 
  150.             Caption         =   "0"
  151.             Height          =   255
  152.             Left            =   1230
  153.             TabIndex        =   34
  154.             Top             =   540
  155.             Width           =   1005
  156.          End
  157.          Begin VB.Label lblVideoStream 
  158.             Caption         =   "Video Stream:"
  159.             Height          =   255
  160.             Left            =   2250
  161.             TabIndex        =   33
  162.             Top             =   300
  163.             Width           =   1005
  164.          End
  165.          Begin VB.Label lblVideoStreamValue 
  166.             Caption         =   "0"
  167.             Height          =   255
  168.             Left            =   3330
  169.             TabIndex        =   32
  170.             Top             =   300
  171.             Width           =   255
  172.          End
  173.       End
  174.       Begin VB.CommandButton cmdEnd 
  175.          Caption         =   "&End"
  176.          Height          =   375
  177.          Left            =   2190
  178.          TabIndex        =   6
  179.          ToolTipText     =   "Move to the last frame."
  180.          Top             =   300
  181.          Width           =   975
  182.       End
  183.       Begin VB.CommandButton cmdHome 
  184.          Caption         =   "&Home"
  185.          Height          =   375
  186.          Left            =   150
  187.          TabIndex        =   3
  188.          ToolTipText     =   "Move to the first frame."
  189.          Top             =   300
  190.          Width           =   975
  191.       End
  192.       Begin VB.CommandButton cmdFwdFrame 
  193.          Caption         =   ">"
  194.          Height          =   375
  195.          Left            =   1710
  196.          TabIndex        =   5
  197.          ToolTipText     =   "Move Forward one frame."
  198.          Top             =   300
  199.          Width           =   375
  200.       End
  201.       Begin VB.CommandButton cmdBackFrame 
  202.          Caption         =   "<"
  203.          Height          =   375
  204.          Left            =   1230
  205.          TabIndex        =   4
  206.          ToolTipText     =   "Move backward one frame."
  207.          Top             =   300
  208.          Width           =   375
  209.       End
  210.       Begin MSComctlLib.Slider ctrlSlider 
  211.          Height          =   375
  212.          Left            =   30
  213.          TabIndex        =   7
  214.          ToolTipText     =   "Highlighted portion of the timeline represents the selected video which will be 'Trimmed' from the source clip"
  215.          Top             =   825
  216.          Width           =   7130
  217.          _ExtentX        =   12568
  218.          _ExtentY        =   661
  219.          _Version        =   393216
  220.          Max             =   50
  221.          SelectRange     =   -1  'True
  222.          TextPosition    =   1
  223.       End
  224.       Begin VB.Label lblCurrentTimeValue 
  225.          Caption         =   "0"
  226.          Height          =   255
  227.          Left            =   5070
  228.          TabIndex        =   29
  229.          Top             =   540
  230.          Width           =   1680
  231.       End
  232.       Begin VB.Label lblCurrentTime 
  233.          Caption         =   "Current Time:"
  234.          Height          =   255
  235.          Left            =   3750
  236.          TabIndex        =   28
  237.          Top             =   540
  238.          Width           =   1125
  239.       End
  240.       Begin VB.Label lblCurrentFrameValue 
  241.          Caption         =   "0"
  242.          Height          =   255
  243.          Left            =   5070
  244.          TabIndex        =   27
  245.          Top             =   300
  246.          Width           =   1680
  247.       End
  248.       Begin VB.Label lblCurrentFrame 
  249.          Caption         =   "Current Frame:"
  250.          Height          =   255
  251.          Left            =   3750
  252.          TabIndex        =   26
  253.          Top             =   300
  254.          Width           =   1140
  255.       End
  256.    End
  257.    Begin VB.Frame fraVideoControl 
  258.       Caption         =   "Video Control:"
  259.       Height          =   2415
  260.       Left            =   45
  261.       TabIndex        =   14
  262.       Top             =   3525
  263.       Width           =   7190
  264.       Begin VB.CommandButton cmdPlayback 
  265.          Caption         =   "&Playback"
  266.          Height          =   375
  267.          Left            =   150
  268.          TabIndex        =   2
  269.          ToolTipText     =   "Plays back the video using Media Player"
  270.          Top             =   1875
  271.          Width           =   975
  272.       End
  273.       Begin VB.CommandButton cmdBrowse 
  274.          Caption         =   "&Browse..."
  275.          Height          =   375
  276.          Left            =   150
  277.          TabIndex        =   0
  278.          ToolTipText     =   "Browse for source media."
  279.          Top             =   900
  280.          Width           =   975
  281.       End
  282.       Begin VB.CommandButton cmdWrite 
  283.          Caption         =   "&Write"
  284.          Height          =   375
  285.          Left            =   150
  286.          TabIndex        =   1
  287.          ToolTipText     =   "Exports the trimmed video to an avi file."
  288.          Top             =   1380
  289.          Width           =   975
  290.       End
  291.       Begin MSComctlLib.ProgressBar ctrlProgress 
  292.          Height          =   405
  293.          Left            =   1230
  294.          TabIndex        =   42
  295.          Top             =   1350
  296.          Visible         =   0   'False
  297.          Width           =   5805
  298.          _ExtentX        =   10239
  299.          _ExtentY        =   714
  300.          _Version        =   393216
  301.          Appearance      =   1
  302.       End
  303.       Begin VB.Label lblPlaybackFileName 
  304.          BorderStyle     =   1  'Fixed Single
  305.          Caption         =   "c:\smart.avi"
  306.          Height          =   375
  307.          Left            =   1230
  308.          TabIndex        =   41
  309.          Top             =   1875
  310.          Width           =   5805
  311.       End
  312.       Begin VB.Label lblReadFileName 
  313.          BorderStyle     =   1  'Fixed Single
  314.          Height          =   375
  315.          Left            =   1230
  316.          TabIndex        =   24
  317.          Top             =   900
  318.          Width           =   5805
  319.       End
  320.       Begin VB.Label lblWriteFileName 
  321.          BorderStyle     =   1  'Fixed Single
  322.          Caption         =   "c:\smart.avi"
  323.          Height          =   375
  324.          Left            =   1230
  325.          TabIndex        =   23
  326.          Top             =   1380
  327.          Width           =   5805
  328.       End
  329.       Begin VB.Label lblStartFrame 
  330.          Caption         =   "Start Frame:"
  331.          Height          =   255
  332.          Left            =   150
  333.          TabIndex        =   22
  334.          Top             =   300
  335.          Width           =   1095
  336.       End
  337.       Begin VB.Label lblStartFrameValue 
  338.          Caption         =   "0"
  339.          Height          =   255
  340.          Left            =   1350
  341.          TabIndex        =   21
  342.          Top             =   300
  343.          Width           =   1680
  344.       End
  345.       Begin VB.Label lblStopFrame 
  346.          Caption         =   "Stop Frame:"
  347.          Height          =   255
  348.          Left            =   3270
  349.          TabIndex        =   20
  350.          Top             =   300
  351.          Width           =   1095
  352.       End
  353.       Begin VB.Label lblStopFrameValue 
  354.          Caption         =   "0"
  355.          Height          =   255
  356.          Left            =   4380
  357.          TabIndex        =   19
  358.          Top             =   300
  359.          Width           =   1680
  360.       End
  361.       Begin VB.Label lblStartTime 
  362.          Caption         =   "Start Time:"
  363.          Height          =   255
  364.          Left            =   150
  365.          TabIndex        =   18
  366.          Top             =   540
  367.          Width           =   1095
  368.       End
  369.       Begin VB.Label lblStartTimeValue 
  370.          Caption         =   "0"
  371.          Height          =   255
  372.          Left            =   1350
  373.          TabIndex        =   17
  374.          Top             =   540
  375.          Width           =   1680
  376.       End
  377.       Begin VB.Label lblStopTime 
  378.          Caption         =   "Stop Time:"
  379.          Height          =   255
  380.          Left            =   3270
  381.          TabIndex        =   16
  382.          Top             =   540
  383.          Width           =   1095
  384.       End
  385.       Begin VB.Label lblStopTimeValue 
  386.          Caption         =   "0"
  387.          Height          =   255
  388.          Left            =   4380
  389.          TabIndex        =   15
  390.          Top             =   540
  391.          Width           =   1680
  392.       End
  393.    End
  394.    Begin VB.PictureBox picPreview 
  395.       Height          =   3225
  396.       Left            =   45
  397.       ScaleHeight     =   3165
  398.       ScaleWidth      =   3480
  399.       TabIndex        =   10
  400.       Top             =   270
  401.       Width           =   3540
  402.    End
  403.    Begin VB.Label lblVideoStopFrame 
  404.       Caption         =   "Video Stop Frame:"
  405.       Height          =   240
  406.       Left            =   7305
  407.       TabIndex        =   13
  408.       Top             =   0
  409.       Width           =   3480
  410.    End
  411.    Begin VB.Label lblVideoStartFrame 
  412.       Caption         =   "Video Start Frame:"
  413.       Height          =   240
  414.       Left            =   3660
  415.       TabIndex        =   12
  416.       Top             =   0
  417.       Width           =   3555
  418.    End
  419.    Begin VB.Label lblVideoCurrentFrame 
  420.       Caption         =   "Current Video Frame:"
  421.       Height          =   240
  422.       Left            =   45
  423.       TabIndex        =   11
  424.       Top             =   0
  425.       Width           =   1515
  426.    End
  427.    Begin VB.Image imgPreviewStop 
  428.       BorderStyle     =   1  'Fixed Single
  429.       Height          =   3225
  430.       Left            =   7305
  431.       Stretch         =   -1  'True
  432.       Top             =   270
  433.       Width           =   3540
  434.    End
  435.    Begin VB.Image imgPreviewStart 
  436.       BorderStyle     =   1  'Fixed Single
  437.       Height          =   3225
  438.       Left            =   3675
  439.       Stretch         =   -1  'True
  440.       Top             =   270
  441.       Width           =   3540
  442.    End
  443. Attribute VB_Name = "frmMain"
  444. Attribute VB_GlobalNameSpace = False
  445. Attribute VB_Creatable = False
  446. Attribute VB_PredeclaredId = True
  447. Attribute VB_Exposed = False
  448. '*******************************************************************************
  449. '*       This is a part of the Microsoft DXSDK Code Samples.
  450. '*       Copyright (C) 1999-2000 Microsoft Corporation.
  451. '*       All rights reserved.
  452. '*       This source code is only intended as a supplement to
  453. '*       Microsoft Development Tools and/or SDK documentation.
  454. '*       See these sources for detailed information regarding the
  455. '*       Microsoft samples programs.
  456. '*******************************************************************************
  457. Option Explicit
  458. Option Base 0
  459. Option Compare Text
  460. Private m_dblFPS As Double                         'evaluates to the rate of the currently loaded clip (frames per second)
  461. Private m_boolDirty As Boolean                    'evaluates to true if the UI needs repainted, and the poster frame needs regrabbed
  462. Private m_nFrameCount As Long                   'evaluates to the number of frames in the current clip
  463. Private m_bstrFileName As String                 'evaluates to the filename of the currently loaded clip
  464. Private m_boolLoaded As Boolean                'evaluates to true if we have anything loaded
  465. Private m_boolHasAudio As Boolean            'evaluates to true if the current clip has audio
  466. Private m_objMediaDet As MediaDet            'evaluates to a media detector object which is used to work with stream information
  467. Private Const VIDEO_CLSID As String = "{73646976-0000-0010-8000-00AA00389B71}"  'video clsid
  468. Private Const AUDIO_CLSID As String = "{73647561-0000-0010-8000-00AA00389B71}"  'audio clsid
  469. Private Const POSTER_FRAME_FILENAME As String = "bitmap.bmp"   ' filename to write out poster frames for loading into the UI
  470. Private Const MPLAYER2_INSTALL_LOCATION As String = "c:\program files\windows media player\mplayer2.exe"  'mplayer2.exe
  471. ' **************************************************************************************************************************************
  472. ' * PRIVATE INTERFACE- FORM EVENTS
  473.             ' ******************************************************************************************************************************
  474.             ' * procedure name: Form_Load
  475.             ' * procedure description:  Occurs when a form is loaded.
  476.             ' *
  477.             ' ******************************************************************************************************************************
  478.             Private Sub Form_Load()
  479.             On Local Error GoTo ErrLine
  480.             
  481.             'disable ui
  482.             ctrlSlider.Enabled = False
  483.             cmdHome.Enabled = False
  484.             cmdEnd.Enabled = False
  485.             cmdBrowse.Enabled = True
  486.             cmdWrite.Enabled = False
  487.             cmdSelStart.Enabled = False
  488.             cmdSetStop.Enabled = False
  489.             cmdBackFrame.Enabled = False
  490.             cmdFwdFrame.Enabled = False
  491.             cmdPlayback.Enabled = False
  492.             Exit Sub
  493.             
  494. ErrLine:
  495.             Err.Clear
  496.             Exit Sub
  497.             End Sub
  498.             
  499.             ' ******************************************************************************************************************************
  500.             ' * procedure name: Form_Load
  501.             ' * procedure description:  Occurs when a form is loaded.
  502.             ' *
  503.             ' ******************************************************************************************************************************
  504.             Private Sub Form_Unload(Cancel As Integer)
  505.             On Local Error GoTo ErrLine
  506.             
  507.             'ensure the temporary file has been deleted
  508.             If File_Exists(GetTempDirectory & POSTER_FRAME_FILENAME) Then _
  509.                Call File_Delete(GetTempDirectory & POSTER_FRAME_FILENAME, False, False, False)
  510.             Exit Sub
  511.             
  512. ErrLine:
  513.             Err.Clear
  514.             Exit Sub
  515.             End Sub
  516.             
  517.             
  518.             ' ******************************************************************************************************************************
  519.             ' * procedure name: Form_Initialize
  520.             ' * procedure description:  Occurs when an application creates an instance of a Form, MDIForm, or class.
  521.             ' *
  522.             ' ******************************************************************************************************************************
  523.             Private Sub Form_Initialize()
  524.             On Local Error GoTo ErrLine
  525.             
  526.             'initalize module-level variable(s)
  527.             Set m_objMediaDet = New MediaDet
  528.             Exit Sub
  529.             
  530. ErrLine:
  531.             Err.Clear
  532.             Exit Sub
  533.             End Sub
  534.             
  535.             
  536.             ' ******************************************************************************************************************************
  537.             ' * procedure name: Form_Terminate
  538.             ' * procedure description:  Occurs when all references to an instance of a Form, MDIForm, or class are removed from memory.
  539.             ' *
  540.             ' ******************************************************************************************************************************
  541.             Private Sub Form_Terminate()
  542.             On Local Error GoTo ErrLine
  543.             
  544.             'terminate module-level object(s0
  545.             If ObjPtr(m_objMediaDet) > 0 Then Set m_objMediaDet = Nothing
  546.             Exit Sub
  547.             
  548. ErrLine:
  549.             Err.Clear
  550.             Exit Sub
  551.             End Sub
  552.             
  553.             
  554.             
  555. ' **************************************************************************************************************************************
  556. ' * PRIVATE INTERFACE- CONTROL EVENTS
  557.             ' ******************************************************************************************************************************
  558.             ' * procedure name: cmdPlayback_Click
  559.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  560.             ' *
  561.             ' ******************************************************************************************************************************
  562.             Private Sub cmdPlayback_Click()
  563.             On Local Error GoTo ErrLine
  564.             
  565.             'verify that media player's location is valid
  566.             If File_Exists(MPLAYER2_INSTALL_LOCATION) Then
  567.                'verify that the export location is valid
  568.                If File_Exists(lblPlaybackFileName.Caption) Then
  569.                   Shell (MPLAYER2_INSTALL_LOCATION & Space(1) & lblPlaybackFileName.Caption), vbNormalFocus
  570.                Else: MsgBox "The file could not be found on the specified path: " & _
  571.                         CStr(MPLAYER2_INSTALL_LOCATION & Space(1) & lblPlaybackFileName.Caption), vbExclamation + vbApplicationModal
  572.                End If
  573.             Else: MsgBox "Media player could not be found on the specified path: " & _
  574.                         CStr(MPLAYER2_INSTALL_LOCATION), vbExclamation + vbApplicationModal
  575.             End If
  576.             Exit Sub
  577.             
  578. ErrLine:
  579.             Err.Clear
  580.             Exit Sub
  581.             End Sub
  582.             ' ******************************************************************************************************************************
  583.             ' * procedure name: cmdBackFrame_Click
  584.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  585.             ' *
  586.             ' ******************************************************************************************************************************
  587.             Private Sub cmdBackFrame_Click()
  588.             Dim v As Long
  589.             On Local Error GoTo ErrLine
  590.             
  591.             v = CLng(ctrlSlider.Value)
  592.             v = (v - 1): If v < 0 Then v = 0
  593.             ctrlSlider.Value = v: m_boolDirty = True 'reset to dirty
  594.             lblCurrentFrameValue.Caption = CStr(Trim(Str(ctrlSlider.Value)))
  595.             If m_dblFPS <> 0 Then lblCurrentTimeValue.Caption = CStr(Trim(Str(ctrlSlider.Value / m_dblFPS)))
  596.             Exit Sub
  597.             
  598. ErrLine:
  599.             Err.Clear
  600.             Exit Sub
  601.             End Sub
  602.             
  603.             
  604.             ' ******************************************************************************************************************************
  605.             ' * procedure name: cmdFwdFrame_Click
  606.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  607.             ' *
  608.             ' ******************************************************************************************************************************
  609.             Private Sub cmdFwdFrame_Click()
  610.             Dim v As Long
  611.             On Local Error GoTo ErrLine
  612.             
  613.             v = CLng(ctrlSlider.Value): v = (v + 1)
  614.             If v > m_nFrameCount Then v = m_nFrameCount
  615.             ctrlSlider.Value = v: m_boolDirty = True 'reset to dirty
  616.             lblCurrentFrameValue.Caption = CStr(Trim(Str(ctrlSlider.Value)))
  617.             If m_dblFPS <> 0 Then lblCurrentTimeValue.Caption = CStr(Trim(Str(ctrlSlider.Value / m_dblFPS)))
  618.             Exit Sub
  619.             
  620. ErrLine:
  621.             Err.Clear
  622.             Exit Sub
  623.             End Sub
  624.             
  625.             
  626.             ' ******************************************************************************************************************************
  627.             ' * procedure name: cmdEnd_Click
  628.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  629.             ' *
  630.             ' ******************************************************************************************************************************
  631.             Private Sub cmdEnd_Click()
  632.             On Local Error GoTo ErrLine
  633.             
  634.             ctrlSlider.Value = m_nFrameCount: m_boolDirty = True 'reset to dirty
  635.             lblCurrentFrameValue.Caption = CStr(Trim(Str(ctrlSlider.Value)))
  636.             If m_dblFPS <> 0 Then lblCurrentTimeValue.Caption = CStr(Trim(Str(ctrlSlider.Value / m_dblFPS)))
  637.             Exit Sub
  638.             
  639. ErrLine:
  640.             Err.Clear
  641.             Exit Sub
  642.             End Sub
  643.             
  644.             
  645.             ' ******************************************************************************************************************************
  646.             ' * procedure name: cmdHome_Click
  647.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  648.             ' *
  649.             ' ******************************************************************************************************************************
  650.             Private Sub cmdHome_Click()
  651.             On Local Error GoTo ErrLine
  652.             
  653.             ctrlSlider.Value = 0: m_boolDirty = True 'reset to dirty
  654.             lblCurrentFrameValue.Caption = CStr(Trim(Str(ctrlSlider.Value)))
  655.             If m_dblFPS <> 0 Then lblCurrentTimeValue.Caption = CStr(Trim(Str(ctrlSlider.Value / m_dblFPS)))
  656.             Exit Sub
  657.             
  658. ErrLine:
  659.             Err.Clear
  660.             Exit Sub
  661.             End Sub
  662.             
  663.             
  664.             ' ******************************************************************************************************************************
  665.             ' * procedure name: cmdBrowse_Click
  666.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  667.             ' *
  668.             ' ******************************************************************************************************************************
  669.             Private Sub cmdBrowse_Click()
  670.             Dim nCount As Long
  671.             Dim bstrWriteName As String
  672.             Dim bstrStreamType As String
  673.             Dim intVideoStream As Integer
  674.             Dim objMediaDet As MediaDet
  675.             On Local Error Resume Next
  676.             
  677.             'display the common 'open' dialog
  678.             ctrlCommonDialog.CancelError = True
  679.             ctrlCommonDialog.Filter = "Video Files (*.avi;*.mov)|*.avi;*.mov|"
  680.             ctrlCommonDialog.ShowOpen
  681.             
  682.             If ctrlCommonDialog.FileName <> vbNullString Then
  683.                'assign the filename to the MediaDet
  684.                If File_Exists(ctrlCommonDialog.FileName) Then
  685.                   Set objMediaDet = New MediaDet 'instantiate
  686.                   objMediaDet.FileName = ctrlCommonDialog.FileName
  687.                Else: Exit Sub
  688.                End If
  689.             Else: Exit Sub
  690.             End If
  691.                 
  692.             'fashion a new name to write out
  693.             lblReadFileName.Caption = ctrlCommonDialog.FileName
  694.             bstrWriteName = Left$(ctrlCommonDialog.FileName, Len(ctrlCommonDialog.FileName) - 4) + "_T.avi"
  695.             lblWriteFileName.Caption = bstrWriteName: lblPlaybackFileName.Caption = bstrWriteName
  696.             
  697.             'see if there's any video and audio
  698.             m_boolHasAudio = False
  699.             
  700.             intVideoStream = -1
  701.             For nCount = 0 To objMediaDet.OutputStreams - 1
  702.                 'get the current stream
  703.                 objMediaDet.CurrentStream = nCount
  704.                 'obtain the type of stream (audio/video)
  705.                 bstrStreamType = objMediaDet.StreamTypeB
  706.                 'elect an action based on the stream type
  707.                 If bstrStreamType = VIDEO_CLSID Then
  708.                     'video stream
  709.                     intVideoStream = nCount
  710.                     Call SetDuration(objMediaDet.StreamLength, objMediaDet.FrameRate)
  711.                 ElseIf bstrStreamType = AUDIO_CLSID Then
  712.                     'audio stream
  713.                     m_boolHasAudio = True
  714.                 End If
  715.             Next
  716.             
  717.             'default error
  718.             If intVideoStream = -1 Then
  719.                 MsgBox "The Selected File does not contain a video stream.", vbExclamation
  720.                 Exit Sub
  721.             End If
  722.             
  723.             'assign the instance to module-level
  724.             If ObjPtr(objMediaDet) > 0 Then Set m_objMediaDet = objMediaDet
  725.             If ctrlCommonDialog.FileName <> vbNullString Then m_bstrFileName = ctrlCommonDialog.FileName
  726.             
  727.             'assign the stream info the the ui
  728.             lblStreamsValue.Caption = Trim(Str(objMediaDet.OutputStreams))
  729.             lblVideoStreamValue.Caption = Trim(Str(intVideoStream))
  730.                         
  731.             ' get a poster frame to start out with
  732.             objMediaDet.WriteBitmapBits 0, picPreview.Width / 15, picPreview.Height / 15, GetTempDirectory + POSTER_FRAME_FILENAME
  733.             picPreview.Picture = LoadPicture(GetTempDirectory + POSTER_FRAME_FILENAME)
  734.             
  735.             'assign state
  736.             m_boolLoaded = True
  737.             m_boolDirty = False
  738.             
  739.             'reset scrollbar
  740.             ctrlSlider.Value = 0
  741.             Call ctrlSlider_Scroll
  742.             
  743.             'set  start/stop
  744.             Call cmdSelStart_Click
  745.             Call cmdSetStop_Click
  746.             
  747.             'enable ui
  748.             ctrlSlider.Enabled = True
  749.             cmdHome.Enabled = True
  750.             cmdEnd.Enabled = True
  751.             cmdBrowse.Enabled = True
  752.             cmdWrite.Enabled = True
  753.             cmdSelStart.Enabled = True
  754.             cmdSetStop.Enabled = True
  755.             cmdBackFrame.Enabled = True
  756.             cmdFwdFrame.Enabled = True
  757.             
  758.             'clean-up & dereference
  759.             If ObjPtr(objMediaDet) > 0 Then Set objMediaDet = Nothing
  760.             Exit Sub
  761.             
  762. ErrLine:
  763.             Err.Clear
  764.             Exit Sub
  765.             End Sub
  766.             
  767.             
  768.             
  769.             ' ******************************************************************************************************************************
  770.             ' * procedure name: cmdSelStart_Click
  771.             ' * procedure description:  Occurs when the user presses and then releases a mouse button over an object.
  772.             ' *                                       Set the start frame and show a frame for it.
  773.             ' ******************************************************************************************************************************
  774.             Private Sub cmdSelStart_Click()
  775.             On Local Error GoTo ErrLine
  776.             
  777.             If Not m_boolLoaded Then Exit Sub
  778.             
  779.             'setup the ui
  780.             lblStartTimeValue.Caption = Trim(Str(GetCurrentPos))
  781.             lblStartFrameValue.Caption = Trim(Str(ctrlSlider.Value))
  782.             lblVideoStartFrame.Caption = "Video Start Frame:" & Space(2) & Trim(Str(Round(GetCurrentPos, 2)))
  783.             
  784.             'setup the slider
  785.             If ctrlSlider.Value > ctrlSlider.SelStart Then
  786.                 ctrlSlider.SelStart = ctrlSlider.Value
  787.                 ctrlSlider.SelLength = 0
  788.             Else: ctrlSlider.SelStart = ctrlSlider.Value
  789.             End If
  790.             
  791.             'reset to dirty
  792.             m_boolDirty = True
  793.             'call the timer event proc
  794.             Call tmrTimer_Timer
  795.             'load the picture into the preview pane
  796.             imgPreviewStart.Picture = LoadPicture(GetTempDirectory + POSTER_FRAME_FILENAME)
  797.             Exit Sub
  798.             
  799. ErrLine:
  800.             Err.Clear
  801.             Exit Sub
  802.             End Sub
  803.             
  804.             
  805.             
  806.             ' ******************************************************************************************************************************
  807.             ' * procedure name: cmdSetStop_Click
  808.             ' * procedure description:   Occurs when the user presses and then releases a mouse button over an object.
  809.             ' *                                        Set the stop frame and show a frame for it
  810.             ' ******************************************************************************************************************************
  811.             Private Sub cmdSetStop_Click()
  812.             On Local Error GoTo ErrLine
  813.             
  814.             If Not m_boolLoaded Then Exit Sub
  815.             
  816.             'setup the ui
  817.             lblStopTimeValue.Caption = Trim(Str(GetCurrentPos))
  818.             lblStopFrameValue.Caption = Trim(Str(ctrlSlider.Value))
  819.             lblVideoStopFrame.Caption = "Video Stop Frame:" & Space(2) & Trim(Str(Round(GetCurrentPos, 2)))
  820.             
  821.             'setup the slider
  822.             If ctrlSlider.Value < ctrlSlider.SelStart Then
  823.                 ctrlSlider.SelStart = ctrlSlider.Value
  824.                 ctrlSlider.SelLength = 0
  825.             Else
  826.                 ctrlSlider.SelLength = ctrlSlider.Value - ctrlSlider.SelStart
  827.             End If
  828.             
  829.             'reset to dirty
  830.             m_boolDirty = True
  831.             'call the timer event proc
  832.             Call tmrTimer_Timer
  833.             'load the picture into the preview pane
  834.             imgPreviewStop.Picture = LoadPicture(GetTempDirectory + POSTER_FRAME_FILENAME)
  835.             Exit Sub
  836.             
  837. ErrLine:
  838.             Err.Clear
  839.             Exit Sub
  840.             End Sub
  841.             
  842.             
  843.             
  844.             
  845.             ' ******************************************************************************************************************************
  846.             ' * procedure name: cmdWrite_Click
  847.             ' * procedure description:   Occurs when the user presses and then releases a mouse button over an object.
  848.             ' *                                        Construct a timeline and write out the file using smart recompression.
  849.             ' ******************************************************************************************************************************
  850.             Private Sub cmdWrite_Click()
  851.             Dim nState As Long
  852.             Dim nReturnCode As Long
  853.             Dim dblPosition As Double
  854.             Dim dblDuration As Double
  855.             Dim dblStartTime As Double
  856.             Dim dblStopTime As Double
  857.             
  858.             Dim objMediaEvent As IMediaEvent
  859.             Dim objMediaPosition As IMediaPosition
  860.             Dim objFilterGraphManager As FilgraphManager
  861.             
  862.             Dim objTimeline As AMTimeline
  863.             Dim objSourceObj As AMTimelineObj
  864.             Dim objTrackObject As AMTimelineObj
  865.             Dim objAudioGroupObj As AMTimelineObj
  866.             Dim objVideoGroupObject As AMTimelineObj
  867.             
  868.             Dim objSource As AMTimelineSrc
  869.             Dim objTrack As AMTimelineTrack
  870.             Dim objAudioGroup As AMTimelineGroup
  871.             Dim objVideoGroup As AMTimelineGroup
  872.             Dim objAudioComposition As AMTimelineComp
  873.             Dim objVideoComposition As AMTimelineComp
  874.             Dim objSmartRenderEngine As New SmartRenderEngine
  875.             On Local Error GoTo ErrLine
  876.             
  877.             
  878.             'disable the form
  879.             Call DisableEverything
  880.             
  881.             
  882.             'instantiate a timeline
  883.             Set objTimeline = New AMTimeline
  884.             'create an empty node on the timeline for the video
  885.             objTimeline.CreateEmptyNode objVideoGroupObject, TIMELINE_MAJOR_TYPE_GROUP
  886.             'derive the video group object from the timeline object
  887.             Set objVideoGroup = objVideoGroupObject
  888.             'set the media type of the video group
  889.             objVideoGroup.SetMediaTypeForVB 0
  890.             'append the video group to the timeline
  891.             objTimeline.AddGroup objVideoGroup
  892.             
  893.             
  894.             
  895.             'create an empty node on the timeline for the track
  896.             objTimeline.CreateEmptyNode objTrackObject, TIMELINE_MAJOR_TYPE_TRACK
  897.             'obtain a composition from the video group
  898.             Set objVideoComposition = objVideoGroup
  899.             'inset the track into the composition
  900.             objVideoComposition.VTrackInsBefore objTrackObject, -1
  901.             'derive the track object
  902.             Set objTrack = objTrackObject
  903.             
  904.             
  905.             
  906.             'create an empty node on the timeline for the source clip
  907.             objTimeline.CreateEmptyNode objSourceObj, TIMELINE_MAJOR_TYPE_SOURCE
  908.             'derive the source clip from the timeline object
  909.             Set objSource = objSourceObj
  910.             'query the ui for duration times
  911.             If m_dblFPS > 0 Then
  912.                dblDuration = ctrlSlider.SelLength / m_dblFPS
  913.                dblStartTime = ctrlSlider.SelStart / m_dblFPS
  914.                dblStopTime = dblStartTime + dblDuration
  915.             Else
  916.                dblDuration = ctrlSlider.SelLength / 15
  917.                dblStartTime = ctrlSlider.SelStart / 15
  918.                dblStopTime = dblStartTime + dblDuration
  919.             End If
  920.             'verify start/stop times
  921.             If dblStopTime = 0 Then
  922.                dblStopTime = 1
  923.             ElseIf dblStartTime = dblStopTime Then
  924.                dblStopTime = dblStartTime + 1
  925.             End If
  926.             'set the start/stop times to the source clip
  927.             objSourceObj.SetStartStop2 0, dblDuration
  928.             objSource.SetMediaTimes2 dblStartTime, dblStopTime
  929.             objSource.SetMediaName m_bstrFileName
  930.             'append the source clip to the track
  931.             objTrack.SrcAdd objSourceObj
  932.             
  933.             
  934.             
  935.             If m_boolHasAudio Then
  936.                'create an empty node on the timeline for the audio group
  937.                objTimeline.CreateEmptyNode objAudioGroupObj, TIMELINE_MAJOR_TYPE_GROUP
  938.                'derive the audio group form the timeline object
  939.                Set objAudioGroup = objAudioGroupObj
  940.                'set the media type of the audio group
  941.                objAudioGroup.SetMediaTypeForVB 1
  942.                'append the group to the timeline
  943.                objTimeline.AddGroup objAudioGroup
  944.                
  945.                'create an empty node on the timeline for the track
  946.                objTimeline.CreateEmptyNode objTrackObject, TIMELINE_MAJOR_TYPE_TRACK
  947.                'derive a composition from the audio group
  948.                Set objAudioComposition = objAudioGroup
  949.                'insetr the track into the composition
  950.                objAudioComposition.VTrackInsBefore objTrackObject, -1
  951.                'derive a track object from the timeline object
  952.                Set objTrack = objTrackObject
  953.                
  954.                'create an empty node for the source clip
  955.                objTimeline.CreateEmptyNode objSourceObj, TIMELINE_MAJOR_TYPE_SOURCE
  956.                'derive a source object from the timeline object
  957.                Set objSource = objSourceObj
  958.                'set the start/stop times from the ui
  959.                objSourceObj.SetStartStop2 0, dblDuration
  960.                objSource.SetMediaTimes2 dblStartTime, dblStopTime
  961.                objSource.SetMediaName m_bstrFileName
  962.                'add the source to the track
  963.                objTrack.SrcAdd objSourceObj
  964.             End If
  965.             
  966.             
  967.             
  968.             ' set the recompression format of the video group
  969.             objVideoGroup.SetRecompFormatFromSource objSource
  970.             'set the timeline to the render engine
  971.             objSmartRenderEngine.SetTimelineObject objTimeline
  972.             'connect-up the render engine
  973.             objSmartRenderEngine.ConnectFrontEnd
  974.             'obtain a reference to the filter graph for the timeline
  975.             objSmartRenderEngine.GetFilterGraph objFilterGraphManager
  976.             'add a file writer and mux filter to the filtergraph
  977.             AddFileWriterAndMux objFilterGraphManager, lblWriteFileName.Caption
  978.             'render the output pins & prepare to proceed with smart render
  979.             RenderGroupPins objSmartRenderEngine, objTimeline
  980.             'run the graph, in turn creating the given file
  981.             objFilterGraphManager.Run
  982.             'obtain a media event from the filtergraph manager
  983.             Set objMediaEvent = objFilterGraphManager
  984.             'obtain the position within the graph
  985.             Set objMediaPosition = objFilterGraphManager
  986.             
  987.             
  988.             
  989.             'display the progress during render
  990.             ctrlProgress.Value = 0
  991.             ctrlProgress.Visible = True: lblWriteFileName.Visible = False
  992.             Do: DoEvents
  993.                   'set the progress bar's current position
  994.                   If dblDuration > 0 Then
  995.                         If Round(ctrlProgress.Value, 0) = 100 Then
  996.                            ctrlProgress.Value = 0
  997.                         Else: ctrlProgress.Value = (ctrlProgress.Value + 1)
  998.                         End If
  999.                   End If
  1000.                   'wait until the file has been written, and exit
  1001.                   If ObjPtr(objMediaEvent) > 0 Then
  1002.                   Call objMediaEvent.WaitForCompletion(100, nReturnCode)
  1003.                   If nReturnCode = 1 Then Exit Do
  1004.                   Else: Exit Do
  1005.                   End If
  1006.             Loop
  1007. Cleanup:
  1008.             
  1009.             'clean-up code
  1010.             ctrlProgress.Value = 100
  1011.             ctrlProgress.Visible = False: lblWriteFileName.Visible = True
  1012.             cmdWrite.Enabled = True: Call EnableEverything
  1013.             
  1014.             'scrap the render engine
  1015.             If ObjPtr(objSmartRenderEngine) > 0 Then objSmartRenderEngine.ScrapIt
  1016.             'clean-up & dereference quartz object(s)
  1017.             If ObjPtr(objMediaEvent) > 0 Then Set objMediaEvent = Nothing
  1018.             If ObjPtr(objMediaPosition) > 0 Then Set objMediaPosition = Nothing
  1019.             If ObjPtr(objFilterGraphManager) > 0 Then Set objFilterGraphManager = Nothing
  1020.             'clean-up & dereference dexter timeline object(s)
  1021.             If ObjPtr(objTimeline) > 0 Then Set objTimeline = Nothing
  1022.             If ObjPtr(objSourceObj) > 0 Then Set objSourceObj = Nothing
  1023.             If ObjPtr(objTrackObject) > 0 Then Set objTrackObject = Nothing
  1024.             If ObjPtr(objAudioGroupObj) > 0 Then Set objAudioGroupObj = Nothing
  1025.             If ObjPtr(objVideoGroupObject) > 0 Then Set objVideoGroupObject = Nothing
  1026.             'clean-up & dereference dexter timeline object(s)
  1027.             If ObjPtr(objTrack) > 0 Then Set objTrack = Nothing
  1028.             If ObjPtr(objSource) > 0 Then Set objSource = Nothing
  1029.             If ObjPtr(objAudioGroup) > 0 Then Set objAudioGroup = Nothing
  1030.             If ObjPtr(objVideoGroup) > 0 Then Set objVideoGroup = Nothing
  1031.             If ObjPtr(objAudioComposition) > 0 Then Set objAudioComposition = Nothing
  1032.             If ObjPtr(objVideoComposition) > 0 Then Set objVideoComposition = Nothing
  1033.             If ObjPtr(objSmartRenderEngine) > 0 Then Set objSmartRenderEngine = Nothing
  1034.             Exit Sub
  1035.             
  1036. ErrLine:
  1037.             Select Case Err.Number
  1038.                 Case 5
  1039.                    MsgBox "Error creating file.  Verify that the start/stop times are valid before continuing.", vbExclamation + vbApplicationModal
  1040.                    Err.Clear: GoTo Cleanup
  1041.                 Case 287
  1042.                    Err.Clear: Resume Next
  1043.                 Case Else
  1044.             End Select
  1045.             Exit Sub
  1046.             End Sub
  1047.             
  1048.             ' ******************************************************************************************************************************
  1049.             ' * procedure name: ctrlSlider_Scroll
  1050.             ' * procedure description:  ctrlSlider scroll event.
  1051.             ' *
  1052.             ' ******************************************************************************************************************************
  1053.             Private Sub ctrlSlider_Scroll()
  1054.             On Local Error GoTo ErrLine
  1055.             
  1056.             If m_boolLoaded Then
  1057.                'reset the label caption's
  1058.                lblCurrentFrameValue.Caption = CStr(Trim(Str(ctrlSlider.Value)))
  1059.                If m_dblFPS <> 0 Then lblCurrentTimeValue.Caption = CStr(Trim(Str(ctrlSlider.Value / m_dblFPS)))
  1060.                'reset to dirty
  1061.                m_boolDirty = True
  1062.             End If
  1063.             Exit Sub
  1064.             
  1065. ErrLine:
  1066.             Err.Clear
  1067.             Exit Sub
  1068.             End Sub
  1069.             
  1070.             ' ******************************************************************************************************************************
  1071.             ' * procedure name: tmrTimer_Timer
  1072.             ' * procedure description:  Occurs when a preset interval for a Timer control has elapsed.
  1073.             ' *                                        If the UI is dirty, go grab a video frame and draw it.
  1074.             ' ******************************************************************************************************************************
  1075.             Private Sub tmrTimer_Timer()
  1076.             On Local Error GoTo ErrLine
  1077.             
  1078.             If m_boolDirty Then
  1079.                'reset to not dirty
  1080.                m_boolDirty = False
  1081.                'write out the current frame to the given bitmap file
  1082.                m_objMediaDet.WriteBitmapBits GetCurrentPos, picPreview.Width / 15, picPreview.Height / 15, GetTempDirectory + POSTER_FRAME_FILENAME
  1083.                'load the picture into the preview pane
  1084.                picPreview.Picture = LoadPicture(GetTempDirectory + POSTER_FRAME_FILENAME)
  1085.             End If
  1086.             Exit Sub
  1087.             
  1088. ErrLine:
  1089.             Err.Clear
  1090.             Exit Sub
  1091.             End Sub
  1092.             
  1093.             
  1094.             
  1095. ' **************************************************************************************************************************************
  1096. ' * PRIVATE INTERFACE- PROCEDURES
  1097.             ' ******************************************************************************************************************************
  1098.             ' * procedure name: EnableEverything
  1099.             ' * procedure description:  Enables most controls on the form.
  1100.             ' *
  1101.             ' ******************************************************************************************************************************
  1102.             Private Sub EnableEverything()
  1103.             On Local Error GoTo ErrLine
  1104.             
  1105.             'update ui
  1106.             ctrlSlider.Enabled = True
  1107.             cmdBrowse.Enabled = True
  1108.             cmdWrite.Enabled = True
  1109.             cmdSelStart.Enabled = True
  1110.             cmdSetStop.Enabled = True
  1111.             cmdBackFrame.Enabled = True
  1112.             cmdFwdFrame.Enabled = True
  1113.             cmdPlayback.Enabled = True
  1114.             Exit Sub
  1115.             
  1116. ErrLine:
  1117.             Err.Clear
  1118.             Exit Sub
  1119.             End Sub
  1120.             
  1121.             
  1122.             
  1123.             ' ******************************************************************************************************************************
  1124.             ' * procedure name: DisableEverything
  1125.             ' * procedure description:  Disables most controls on the form.
  1126.             ' *
  1127.             ' ******************************************************************************************************************************
  1128.             Private Sub DisableEverything()
  1129.             On Local Error GoTo ErrLine
  1130.             
  1131.             'update ui
  1132.             ctrlSlider.Enabled = False
  1133.             cmdBrowse.Enabled = False
  1134.             cmdWrite.Enabled = False
  1135.             cmdSelStart.Enabled = False
  1136.             cmdSetStop.Enabled = False
  1137.             cmdBackFrame.Enabled = False
  1138.             cmdFwdFrame.Enabled = False
  1139.             cmdPlayback.Enabled = False
  1140.             Exit Sub
  1141.             
  1142. ErrLine:
  1143.             Err.Clear
  1144.             Exit Sub
  1145.             End Sub
  1146.             
  1147.             
  1148.             ' ******************************************************************************************************************************
  1149.             ' * procedure name: SetDuration
  1150.             ' * procedure description:  Sets the status within the context of the ui given the duration and the rate.
  1151.             ' *
  1152.             ' ******************************************************************************************************************************
  1153.             Private Sub SetDuration(dblDuration As Double, dblFPS As Double)
  1154.             On Local Error GoTo ErrLine
  1155.             
  1156.             'set module-level data
  1157.             m_dblFPS = dblFPS
  1158.             m_nFrameCount = (dblDuration * dblFPS)
  1159.             
  1160.             'setup / update the UI
  1161.             ctrlSlider.SelStart = 0
  1162.             ctrlSlider.SelLength = 0
  1163.             ctrlSlider.Min = 0
  1164.             ctrlSlider.Max = m_nFrameCount
  1165.             ctrlSlider.LargeChange = (m_nFrameCount / 10)
  1166.             ctrlSlider.SmallChange = (m_nFrameCount / 100)
  1167.             ctrlSlider.TickFrequency = 100
  1168.             lblStartTimeValue.Caption = 0
  1169.             lblStopTimeValue.Caption = 0
  1170.             lblFPSValue.Caption = Trim(Str(Format(dblFPS, "##.##")))
  1171.             Exit Sub
  1172.             
  1173. ErrLine:
  1174.             Err.Clear
  1175.             Exit Sub
  1176.             End Sub
  1177.             
  1178.             
  1179.             
  1180.             ' ******************************************************************************************************************************
  1181.             ' * procedure name: GetDuration
  1182.             ' * procedure description:  Returns the duration of the loaded media given the frame count divided by the rate.
  1183.             ' *
  1184.             ' ******************************************************************************************************************************
  1185.             Private Function GetDuration() As Double
  1186.             On Local Error GoTo ErrLine
  1187.             
  1188.             If m_dblFPS = 0 Then Exit Function
  1189.             GetDuration = CDbl((m_nFrameCount / m_dblFPS))
  1190.             Exit Function
  1191.             
  1192. ErrLine:
  1193.             Err.Clear
  1194.             Exit Function
  1195.             End Function
  1196.             
  1197.             
  1198.             
  1199.             ' ******************************************************************************************************************************
  1200.             ' * procedure name: GetCurrentPos
  1201.             ' * procedure description:  Returns the current position given the slider's value divided by the rate.
  1202.             ' *
  1203.             ' ******************************************************************************************************************************
  1204.             Private Function GetCurrentPos() As Double
  1205.             On Local Error GoTo ErrLine
  1206.             
  1207.             If m_dblFPS = 0 Then Exit Function
  1208.             If IsNumeric(ctrlSlider.Value) Then
  1209.                GetCurrentPos = (ctrlSlider.Value / m_dblFPS)
  1210.             End If
  1211.             Exit Function
  1212.             
  1213. ErrLine:
  1214.             Err.Clear
  1215.             Exit Function
  1216.             End Function
  1217.