home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / AMOVIE / SDK / _SETUP / COMMON.Z / player.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-03-23  |  3.9 KB  |  152 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   1545
  5.    ClientLeft      =   3915
  6.    ClientTop       =   1530
  7.    ClientWidth     =   4515
  8.    Height          =   1950
  9.    Left            =   3855
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   1545
  12.    ScaleWidth      =   4515
  13.    Top             =   1185
  14.    Width           =   4635
  15.    Begin VB.Timer Timer1
  16.       Interval        =   200
  17.       Left            =   3720
  18.       Top             =   1200
  19.    End
  20.    Begin VB.CommandButton StopButton
  21.       Caption         =   "&Stop"
  22.       Height          =   495
  23.       Left            =   2160
  24.       TabIndex        =   3
  25.       Top             =   120
  26.       Width           =   735
  27.    End
  28.    Begin VB.CommandButton PlayButton
  29.       Caption         =   "&Play"
  30.       Height          =   495
  31.       Left            =   1200
  32.       TabIndex        =   2
  33.       Top             =   120
  34.       Width           =   735
  35.    End
  36.    Begin VB.CommandButton OpenButton
  37.       Caption         =   "&Open"
  38.       Height          =   495
  39.       Left            =   240
  40.       TabIndex        =   0
  41.       Top             =   120
  42.       Width           =   735
  43.    End
  44.    Begin ComctlLib.Slider Slider1
  45.       Height          =   375
  46.       Left            =   240
  47.       TabIndex        =   1
  48.       Top             =   840
  49.       Width           =   3735
  50.       _Version        =   65536
  51.       _ExtentX        =   6588
  52.       _ExtentY        =   661
  53.       _StockProps     =   64
  54.    End
  55.    Begin MSComDlg.CommonDialog CommonDialog1
  56.       Left            =   3240
  57.       Top             =   1200
  58.       _Version        =   65536
  59.       _ExtentX        =   847
  60.       _ExtentY        =   847
  61.       _StockProps     =   0
  62.    End
  63. Attribute VB_Name = "Form1"
  64. Attribute VB_Creatable = False
  65. Attribute VB_Exposed = False
  66. Dim pMC As Object
  67. Dim bOpen As Boolean
  68. Dim bPlay As Boolean
  69. Dim bSeeking As Boolean
  70. Private Sub Form_Load()
  71. Set pMC = Nothing
  72. bOpen = False
  73. bPlay = False
  74. bSeeking = False
  75. End Sub
  76. Private Sub OpenButton_Click()
  77.     If bPlay Then pMC.Stop
  78.     If bOpen Then Set pMC = Nothing
  79.     bOpen = False
  80.     Set pMC = New FilgraphManager
  81.     CommonDialog1.ShowOpen
  82.     pMC.RenderFile CommonDialog1.filename
  83.     Rem make window appear
  84.     Dim pVW As IVideoWindow
  85.     Set pVW = pMC
  86.     pVW.Visible = True
  87.     Set pVW = Nothing
  88.     bOpen = True
  89. End Sub
  90. Private Sub PlayButton_Click()
  91.     If Not bOpen Then Exit Sub
  92.     If bPlay Then Exit Sub
  93.     pMC.Run
  94.     bPlay = True
  95.     OpenButton.Enabled = False
  96.     PlayButton.Enabled = False
  97. End Sub
  98. Private Sub Slider1_Change()
  99. bSeeking = False
  100. If Not bPlay Then
  101. pMC.Stop
  102. pMC.Run
  103. End If
  104. End Sub
  105. Private Sub Slider1_Scroll()
  106. If Not bOpen Then Exit Sub
  107. bSeeking = True
  108. pMC.Pause
  109. Dim pMP As IMediaPosition
  110. Set pMP = pMC
  111. Dim v As Double
  112. v = Slider1.Value - Slider1.Min
  113. v = v / Slider1.Max * pMP.Duration
  114. pMP.CurrentPosition = v
  115. Set pMP = Nothing
  116. End Sub
  117. Private Sub StopButton_Click()
  118.     If Not bOpen Then Exit Sub
  119.     pMC.Stop
  120.     bPlay = False
  121.     OpenButton.Enabled = True
  122.     PlayButton.Enabled = True
  123. End Sub
  124. Private Sub Timer1_Timer()
  125.     If Not bOpen Then Exit Sub
  126.     If bSeeking Then Exit Sub
  127.     Dim pMP As IMediaPosition
  128.     Set pMP = pMC
  129.     Dim curpos As Double
  130.     Dim length As Double
  131.     Dim mark As Long
  132.     curpos = pMP.CurrentPosition
  133.     length = pMP.Duration
  134.     mark = (curpos / length) * 10
  135.     If Slider1.Value <> mark Then
  136.         Slider1.Value = mark
  137.     End If
  138.     Set pMP = Nothing
  139.     If Not bPlay Then Exit Sub
  140.     Dim pME As IMediaEvent
  141.     Dim EventCode As Long
  142.     Set pME = pMC
  143.     On Error Resume Next
  144.     pME.WaitForCompletion 0, EventCode
  145.     Set pME = Nothing
  146.     If EventCode = 0 Then Exit Sub
  147.     pMC.Stop
  148.     bPlay = False
  149.     OpenButton.Enabled = True
  150.     PlayButton.Enabled = True
  151. End Sub
  152.