Do While (EOF(1) = False) '为什么?
keynumber = keynumber + 1
Input #14, a!
Input #14, keyframe(keynumber)
Loop
下面是 源码Private Sub CmdPlayKey_Click() '播放
On Error GoTo errhandleDim pmp As IMediaPosition
'加载要打开的文件以及其他初始化操作
Set pMCKey = New FilgraphManager
CmdPkey.Enabled = True
CmdShowNext.Enabled = False
CmdShowPre.Enabled = False
CmdKeyDsp.Enabled = False
PicKey(0).Visible = False
LblKey(0).Visible = False
For i = 1 To PicKey.UBound
Unload LblKey(i)
Unload PicKey(i)
Next i
Open playkeyfile For Input As #14
Input #14, mpeg2file
keyfrate = GetKeyFrame(mpeg2file, 1, "a")
pMCKey.RenderFile mpeg2file
PicKeyTV.Visible = True Set pVW = pMCKey pVW.WindowStyle = CLng(&H6000000)
pVW.Left = 0 pVW.Top = 0 OldWidth = pVW.Width OldHeight = pVW.Height'以下代码用于调整显示画面大小适应输出框
If OldWidth - 50 > OldHeight Then
pVW.Width = Pickeyform.Width / 15
pVW.Height = OldHeight / OldWidth * pVW.Width
PicKeyTV.Height = pVW.Height * 15
PicKeyTV.Width = pVW.Width * 15
PicKeyTV.Top = (Pickeyform.Height - PicKeyTV.Height) / 2
PicKeyTV.Left = 0
Else
pVW.Height = (Pickeyform.Height - 750) / 15
pVW.Width = OldWidth / OldHeight * pVW.Height
PicKeyTV.Height = pVW.Height * 15
PicKeyTV.Width = pVW.Width * 15
PicKeyTV.Top = 255
PicKeyTV.Left = (Pickeyform.Width - PicKeyTV.Width) / 2
End If
PicKeyTV.Visible = True
Set pmp = pMCKey
'设置滚动条显示范围
' If pMP.Duration * keyfrate > 2 Then Slider1.Max = Fix(pMP.Duration * keyfrate) Else Slider1.Max = 2
' Slider1.TickFrequency = Slider1.Max / 10
' Slider1.SelLength = Slider1.Max - 1
' Label1.Caption = Slider1.Max
' Label3.Caption = pMP.Duration
pVW.Owner = PicKeyTV.hWnd
DoEvents
pMCKey.Run
DoEvents
pMCKey.Pause
pmp.CurrentPosition = 0
Set pmp = Nothing
'读取关键帧所在位置
'keyfile$ = Mid(CommonDialog1.filename, 1, Len(CommonDialog1.filename) - 4) & "keyframe.txt"
'Open keyfile$ For Input As #1
keynumber = 0
Do While (EOF(1) = False) '为什么?
keynumber = keynumber + 1
Input #14, a!
Input #14, keyframe(keynumber)
Loop
Close 14
Timer2.Enabled = True
' Call CmdShowKey_Click(showMpgBZ) '用来刷新
Exit Sub
errhandle:
Close 14
' Timer2.Enabled = True 'my add
Resume
End Sub
keynumber = keynumber + 1
Input #14, a!
Input #14, keyframe(keynumber)
Loop
下面是 源码Private Sub CmdPlayKey_Click() '播放
On Error GoTo errhandleDim pmp As IMediaPosition
'加载要打开的文件以及其他初始化操作
Set pMCKey = New FilgraphManager
CmdPkey.Enabled = True
CmdShowNext.Enabled = False
CmdShowPre.Enabled = False
CmdKeyDsp.Enabled = False
PicKey(0).Visible = False
LblKey(0).Visible = False
For i = 1 To PicKey.UBound
Unload LblKey(i)
Unload PicKey(i)
Next i
Open playkeyfile For Input As #14
Input #14, mpeg2file
keyfrate = GetKeyFrame(mpeg2file, 1, "a")
pMCKey.RenderFile mpeg2file
PicKeyTV.Visible = True Set pVW = pMCKey pVW.WindowStyle = CLng(&H6000000)
pVW.Left = 0 pVW.Top = 0 OldWidth = pVW.Width OldHeight = pVW.Height'以下代码用于调整显示画面大小适应输出框
If OldWidth - 50 > OldHeight Then
pVW.Width = Pickeyform.Width / 15
pVW.Height = OldHeight / OldWidth * pVW.Width
PicKeyTV.Height = pVW.Height * 15
PicKeyTV.Width = pVW.Width * 15
PicKeyTV.Top = (Pickeyform.Height - PicKeyTV.Height) / 2
PicKeyTV.Left = 0
Else
pVW.Height = (Pickeyform.Height - 750) / 15
pVW.Width = OldWidth / OldHeight * pVW.Height
PicKeyTV.Height = pVW.Height * 15
PicKeyTV.Width = pVW.Width * 15
PicKeyTV.Top = 255
PicKeyTV.Left = (Pickeyform.Width - PicKeyTV.Width) / 2
End If
PicKeyTV.Visible = True
Set pmp = pMCKey
'设置滚动条显示范围
' If pMP.Duration * keyfrate > 2 Then Slider1.Max = Fix(pMP.Duration * keyfrate) Else Slider1.Max = 2
' Slider1.TickFrequency = Slider1.Max / 10
' Slider1.SelLength = Slider1.Max - 1
' Label1.Caption = Slider1.Max
' Label3.Caption = pMP.Duration
pVW.Owner = PicKeyTV.hWnd
DoEvents
pMCKey.Run
DoEvents
pMCKey.Pause
pmp.CurrentPosition = 0
Set pmp = Nothing
'读取关键帧所在位置
'keyfile$ = Mid(CommonDialog1.filename, 1, Len(CommonDialog1.filename) - 4) & "keyframe.txt"
'Open keyfile$ For Input As #1
keynumber = 0
Do While (EOF(1) = False) '为什么?
keynumber = keynumber + 1
Input #14, a!
Input #14, keyframe(keynumber)
Loop
Close 14
Timer2.Enabled = True
' Call CmdShowKey_Click(showMpgBZ) '用来刷新
Exit Sub
errhandle:
Close 14
' Timer2.Enabled = True 'my add
Resume
End Sub
keynumber = 0
Do While (EOF(1) = False) '为什么?
keynumber = keynumber + 1
Input #14, a!
Input #14, keyframe(keynumber)
Loop
Close 14
文件号不一致,把他们统一成 1 或 14, 很可能是代码有误
我提一点额外的建议:不要使用固定文件号,使用 freefile 函数获得一个安全文件号
这样改
dim fn as long
fn=freefile
Open keyfile$ For Input As #fn
keynumber = 0
Do While (EOF(1) = False) '为什么?
keynumber = keynumber + 1
Input #fn, a!
Input #fn, keyframe(keynumber)
Loop
Close #fn
这样处理后安全性就好多了,出现笔误的机会也更少
fn=freefile
Open keyfile$ For Input As #fn
keynumber = 0
Do While (EOF(fn) = False) '为什么?
keynumber = keynumber + 1
Input #fn, a!
Input #fn, keyframe(keynumber)
Loop
Close #fn