VB-Homepage Tipp 089

AVI-Files laden und abspielen

Hier soll an Hand eines kleinen VB3 - Projektes vermittelt werden, wie man AVI Dateien lädt und abspielt.
Das dazu wirklich nicht viel gehört, werden Sie selber merken.

Aviplay.mak
AVIPLAY.FRM
CMDIALOG.VBX
GAUGE.VBX
MCI.VBX
ProjWinSize=88,436,248,215
ProjWinShow=2
IconForm="Form1"
Title="AVIPLAYER"
ExeName="AVIPLAY.EXE"

Aviplay.frm
VERSION 2.00
Begin Form Form1
BackColor = &H00808000&
BorderStyle = 3 'Fixed Double
Caption = "VB-Homepage Tipp"
ClientHeight = 1830
ClientLeft = 3195
ClientTop = 4350
ClientWidth = 2775
ClipControls = 0 'False
ControlBox = 0 'False
Height = 2235
Left = 3135
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1830
ScaleWidth = 2775
Top = 4005
Width = 2895
Begin Timer Timer1
Interval = 1000
Left = 6840
Top = 600
End
Begin Frame Frame1
BackColor = &H00808000&
Caption = "Prozent"
ForeColor = &H00FFFFFF&
Height = 735
Left = 0
TabIndex = 7
Top = 1080
Width = 2775
Begin Gauge Gauge1
Autosize = -1 'True
BackColor = &H00800000&
ForeColor = &H000080FF&
Height = 255
InnerBottom = 5
InnerLeft = 5
InnerRight = 5
InnerTop = 5
Left = 120
Max = 100
NeedleWidth = 1
TabIndex = 8
Top = 240
Width = 2535
End
Begin Label Label2
BackStyle = 0 'Transparent
Caption = "0% | 100%"
Height = 255
Left = 120
TabIndex = 9
Top = 480
Width = 2535
End
End
Begin CommandButton Command2
Caption = "Ende"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 285
Left = 2120
TabIndex = 6
Top = 480
Width = 615
End
Begin TextBox Text2
BackColor = &H00808000&
BorderStyle = 0 'None
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 225
Left = 1080
TabIndex = 3
Text = "0"
Top = 480
Width = 375
End
Begin TextBox Text1
BackColor = &H00808000&
BorderStyle = 0 'None
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 225
Left = 1080
TabIndex = 2
Text = "0"
Top = 720
Width = 375
End
Begin CommandButton Command1
Caption = "Öffnen"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 285
Left = 1460
TabIndex = 1
Top = 480
Width = 615
End
Begin CommonDialog CMDialog1
DefaultExt = ".avi"
Filter = "AVI files | *.avi"
Left = 6840
Top = 0
End
Begin MMControl MMControl1
DeviceType = " "
EjectVisible = 0 'False
Height = 375
Left = 0
RecordVisible = 0 'False
TabIndex = 0
Top = 0
UpdateInterval = 500
Width = 2760
End
Begin Label Label1
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "Bild aktuell:"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Left = 0
TabIndex = 5
Top = 480
Width = 975
End
Begin Label L
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "Bild gesamt:"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 255
Left = 0
TabIndex = 4
Top = 720
Width = 975
End
End
Sub Command1_Click ()
cmdialog1.Action = 1 ' 0pen file
mmcontrol1.Command = "close"
mmcontrol1.DeviceType = "AVIVideo"
mmcontrol1.FileName = cmdialog1.FileName
mmcontrol1.Command = "Open"
text1.Text = mmcontrol1.Length
text2.Text = mmcontrol1.Position
End Sub
Sub Command2_Click ()
Unload form1
Set form1 = Nothing
End
End Sub
Sub MMControl1_PlayClick (Cancel As Integer)
text1.Text = mmcontrol1.Length
text2.Text = mmcontrol1.Position
End Sub
Sub MMControl1_StatusUpdate ()
text2.Text = mmcontrol1.Position
gauge1.Value = mmcontrol1.Position
End Sub
Sub MMControl1_StopClick (Cancel As Integer)
mmcontrol1.FileName = ""
mmcontrol1.Command = "Close"
End Sub
Sub Timer1_Timer ()
If Val(text1.Text) > 1 Then
gauge1.Max = Val(text1.Text)
Else
gauge1.Max = 100
End If
End Sub

Um den Code zu nutzen, erstellen Sie sich mit einem Editor (ZBsp. Notepad) Dateien, die Sie wie beschrieben benennen und den jeweiligen Code hinein kopieren.
Rufen Sie dann die *.mak Datei aus dem Dateimanager auf oder starten Ihr VB-Programm und öffnen das Projekt.


Tipp-Download

Quelle :

Zurück zur Übersichtsseite