Bon prenons par exemple :
Dans un module (je met juste les fonciton essentiels :
Private Declare Function GetShortPathNameA Lib "kernel32" ( _
ByVal lpszLongPath As String, ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Function OpenMovie(FileName As String, DestHnwd As Long) As String
Dim Alias As Integer
Alias = Int(Rnd() * &H7FFF) + 1
Dim BufferNom As String * 255
Dim BufferLen As Long
Dim ShortFileName As String
BufferLen = GetShortPathNameA(FileName, BufferNom, 255)
ShortFileName$ = Left$(BufferNom, BufferLen)
Call mciSendString( _
"open MPEGVideo!" & ShortFileName$ & " alias " & Alias & " parent " & _
DestHnwd & " Style " & CStr(&H40000000), 0&, 0&, 0&)
OpenMovie = Alias
End Function
Public Sub PlayMovie(VideoId As Integer)
Call mciSendString("play " & VideoId, 0, 0, 0)
End Sub
Public Sub StopMovie(VideoId As Integer)
Call mciSendString("stop " & VideoId, 0, 0, 0)
End Sub
Public Function GetMovieLength(VideoId As Integer) As Long
Dim TDur As String * 128
Call mciSendString("set " & VideoId & " time format ms", 0, 0, 0)
Call mciSendString("status " & VideoId & " length", TDur, 128, 0)
GetMovieLength = Val(TDur)
End Function
Public Function GetMoviePosition(VideoId As Integer) As Long
Dim TDur As String * 128
Call mciSendString("set " & VideoId & " time format ms", 0, 0, 0)
Call mciSendString("status " & VideoId & " position wait", TDur, 128, 0)
GetMoviePosition = Val(TDur)
End Function
Public Sub CloseMovie(VideoId As Integer)
Call mciSendString("close " & VideoId, 0, 0, 0)
End Sub
Public Sub CloseAllMovie()
Call mciSendString("close all", 0, 0, 0)
End Sub,
----
(Coloration syntaxique automatique par Kenji)
Dans la form de démarrage (avac un bouton) :
Private Sub Command1_Click()
Dim tt As New FormMovie
tt.Show
End Sub ,
----
(Coloration syntaxique automatique par Kenji)
Et dans une autre form qu'on appellera FormMovie et contenant une CommonDialog nommée CDlgOpen :
Dim FileName As String
Dim VideoId As Integer
Private Sub Form_Load()
CDlgOpen.Filter = "Avi Files (*.avi)|*.avi|Mpeg Files (*.mpeg)|*.mpeg|Mpg Files (*.mpg)|*.mpg|Mov Files (*.mov)|*.mov|All Files (*.*)|*.*"
CDlgOpen.ShowOpen
FileName = CDlgOpen.FileName
VideoId = OpenMovie(FileName, Me.hWnd)
Call PlayMovie(VideoId)
End Sub
Private Sub Form_Terminate()
Call CloseMovie(VideoId)
End Sub ,
----
(Coloration syntaxique automatique par Kenji)
__________
Kenji