Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

lire une vidéo avi ou mpg avec MCI

8 réponses
Avatar
DAN
bonjour à tous.
ou puis je trouver un exemple et des explications en français pour la
lecture de vidéo rn utilisant le controle mci mmcontrole.
D'avance merci de votre aide.
Dan

8 réponses

Avatar
Jean-Marc
"DAN" a écrit dans le message de
news:4307127d$0$21295$
bonjour à tous.
ou puis je trouver un exemple et des explications en français pour la
lecture de vidéo rn utilisant le controle mci mmcontrole.
D'avance merci de votre aide.



Hello,

dans le projet, ajouter le composant mci:
Projets/Composnants, choisir "Microsoft Multimedia Control 6.0"
(mci32.ocx)

On pilote ce controle via sa propriété Command.
Voici pour ouvrir une vidéo:

Private Sub Command1_Click()

MMControl1.FileName = "c:windowsclock.avi"
MMControl1.Command = "Open"
MMControl1.Command = "Play"

End Sub

Tout le reste est dans la doc.

--
Jean-marc
"There are only 10 kind of people
those who understand binary and those who don't."
mailto: remove '_no_spam_' ;
Avatar
DAN
Merci bien.
j'ai trouvé sauf que je ne parviens pas a ouvrir ma vidéo dans uns
picturebox je supose que l'on dois l'indiquer dans play pmais coment?

"Jean-Marc" a écrit dans le message de news:
43071e96$0$23543$
"DAN" a écrit dans le message de
news:4307127d$0$21295$
bonjour à tous.
ou puis je trouver un exemple et des explications en français pour la
lecture de vidéo rn utilisant le controle mci mmcontrole.
D'avance merci de votre aide.



Hello,

dans le projet, ajouter le composant mci:
Projets/Composnants, choisir "Microsoft Multimedia Control 6.0"
(mci32.ocx)

On pilote ce controle via sa propriété Command.
Voici pour ouvrir une vidéo:

Private Sub Command1_Click()

MMControl1.FileName = "c:windowsclock.avi"
MMControl1.Command = "Open"
MMControl1.Command = "Play"

End Sub

Tout le reste est dans la doc.

--
Jean-marc
"There are only 10 kind of people
those who understand binary and those who don't."
mailto: remove '_no_spam_' ;



Avatar
Jean-Marc
Hello,

pour ce que tu veux faire, tu ne peux pas utiliser un PictureBox.
Tu dois utiliser un autre composant.

Il faut ajouter à ton projet le composant:
Microsoft Common Controls-2 5.0 ou 6.0. Cela va ajouter
quelques nouveaux controles dont le controle Animation.

Tu places ce controle sur ta forme (comme un Picture Box).

Par défaut le nom sera "Animation1"

Pour l'utiliser:

Private Sub Command1_Click()
Animation1.Open ("c:windowsclock.avi")
Animation1.Play
End Sub

et voila :-)

--
Jean-marc
"There are only 10 kind of people
those who understand binary and those who don't."
mailto: remove '_no_spam_' ;

--
Jean-marc
"There are only 10 kind of people
those who understand binary and those who don't."
mailto: remove '_no_spam_' ;

"DAN" a écrit dans le message de
news:43074e90$0$21300$
Merci bien.
j'ai trouvé sauf que je ne parviens pas a ouvrir ma vidéo dans uns
picturebox je supose que l'on dois l'indiquer dans play pmais coment?

"Jean-Marc" a écrit dans le message de


news:
43071e96$0$23543$
> "DAN" a écrit dans le message de
> news:4307127d$0$21295$
>> bonjour à tous.
>> ou puis je trouver un exemple et des explications en français pour la
>> lecture de vidéo rn utilisant le controle mci mmcontrole.
>> D'avance merci de votre aide.
>
> Hello,
>
> dans le projet, ajouter le composant mci:
> Projets/Composnants, choisir "Microsoft Multimedia Control 6.0"
> (mci32.ocx)
>
> On pilote ce controle via sa propriété Command.
> Voici pour ouvrir une vidéo:
>
> Private Sub Command1_Click()
>
> MMControl1.FileName = "c:windowsclock.avi"
> MMControl1.Command = "Open"
> MMControl1.Command = "Play"
>
> End Sub
>
> Tout le reste est dans la doc.
>
> --
> Jean-marc
> "There are only 10 kind of people
> those who understand binary and those who don't."
> mailto: remove '_no_spam_' ;
>




Avatar
DAN
es tu certain u'il faut ajouter Microsoft Common Controls6.0. ce controle
m'indique un teléphone dans un carré et il ne connait pas les
instructions play et open.

pour le moment mon code fonctionne mais ne mz permet pas de positionner
ma vidéo dans un controle,le voici pour plus de clareté:
***************
Sub Musique(Chemin As String)
Dim TypeDeFichier As String
Dim Extension As String

Extension = LCase(Right(Chemin, 3))

Select Case Extension
Case "mid", "rmi"
TypeDeFichier = "sequencer"
Case "wav"
TypeDeFichier = "waveaudio"
Case "avi"
TypeDeFichier = "avivideo"
Case "mpg"
TypeDeFichier = "MPEGVideo"
Case "mov", "jpg", "pic"
TypeDeFichier = "QTWVideo"
End Select



mci.Command = "close" 'Précaution
'Spécifie quel type de fichier il va ouvrir:
mci.DeviceType = TypeDeFichier
'spécifie le chemin du fichier à ouvrir:
mci.FileName = Chemin
mci.Top = Form1.Top
mci.Left = Form1.Left
mci.Width = 1000
mci.Height = 1000
mci.Command = "open" 'Ouvre le fichier
mci.Command = "play" 'Joue le fichier

End Sub

' --------------------------------------------------


'--------------------------------------------------
Private Sub Command1_Click()
Musique ("c:windowsclock.avi")
End Sub



"Jean-Marc" a écrit dans le message de news:
4307846a$0$23754$
Hello,

pour ce que tu veux faire, tu ne peux pas utiliser un PictureBox.
Tu dois utiliser un autre composant.

Il faut ajouter à ton projet le composant:
Microsoft Common Controls-2 5.0 ou 6.0. Cela va ajouter
quelques nouveaux controles dont le controle Animation.

Tu places ce controle sur ta forme (comme un Picture Box).

Par défaut le nom sera "Animation1"

Pour l'utiliser:

Private Sub Command1_Click()
Animation1.Open ("c:windowsclock.avi")
Animation1.Play
End Sub

et voila :-)

--
Jean-marc
"There are only 10 kind of people
those who understand binary and those who don't."
mailto: remove '_no_spam_' ;

--
Jean-marc
"There are only 10 kind of people
those who understand binary and those who don't."
mailto: remove '_no_spam_' ;

"DAN" a écrit dans le message de
news:43074e90$0$21300$
Merci bien.
j'ai trouvé sauf que je ne parviens pas a ouvrir ma vidéo dans uns
picturebox je supose que l'on dois l'indiquer dans play pmais coment?

"Jean-Marc" a écrit dans le message de


news:
43071e96$0$23543$
> "DAN" a écrit dans le message de
> news:4307127d$0$21295$
>> bonjour à tous.
>> ou puis je trouver un exemple et des explications en français pour
>> la
>> lecture de vidéo rn utilisant le controle mci mmcontrole.
>> D'avance merci de votre aide.
>
> Hello,
>
> dans le projet, ajouter le composant mci:
> Projets/Composnants, choisir "Microsoft Multimedia Control 6.0"
> (mci32.ocx)
>
> On pilote ce controle via sa propriété Command.
> Voici pour ouvrir une vidéo:
>
> Private Sub Command1_Click()
>
> MMControl1.FileName = "c:windowsclock.avi"
> MMControl1.Command = "Open"
> MMControl1.Command = "Play"
>
> End Sub
>
> Tout le reste est dans la doc.
>
> --
> Jean-marc
> "There are only 10 kind of people
> those who understand binary and those who don't."
> mailto: remove '_no_spam_' ;
>







Avatar
Jean-Marc
"DAN" a écrit dans le message de
news:4307bcd4$0$21298$
es tu certain u'il faut ajouter Microsoft Common Controls6.0. ce controle
m'indique un teléphone dans un carré et il ne connait pas les
instructions play et open.



Tu as inséré un:
"Microsoft Comm Control 6.0"
=> C'est le controle pour gérer le PORT SERIE !
il faut un:
"Microsoft Common Controls-2 5.0"
=> Celui la contient ce que tu veux...

--
Jean-marc
"There are only 10 kind of people
those who understand binary and those who don't."
mailto: remove '_no_spam_' ;
Avatar
DAN
merci bien,cela fonctionne mais il n'accepte pas les fichiers mpg,as tu une
solution?
du coup il ne sagit plus du controle mci et je n'ai pas acces au boutons
de controle? coment proceder?

"Jean-Marc" a écrit dans le message de news:
430830d3$0$10959$
"DAN" a écrit dans le message de
news:4307bcd4$0$21298$
es tu certain u'il faut ajouter Microsoft Common Controls6.0. ce controle
m'indique un teléphone dans un carré et il ne connait pas les
instructions play et open.



Tu as inséré un:
"Microsoft Comm Control 6.0"
=> C'est le controle pour gérer le PORT SERIE !
il faut un:
"Microsoft Common Controls-2 5.0"
=> Celui la contient ce que tu veux...

--
Jean-marc
"There are only 10 kind of people
those who understand binary and those who don't."
mailto: remove '_no_spam_' ;



Avatar
Picalausa François
Hello,

Pour le contrôle mci, je n'ai pas réussi à affecter un parent, mais par les
API mci on peut le faire comme ceci:
Option Explicit

Private Declare Function mciGetErrorString _
Lib "winmm.dll" _
Alias "mciGetErrorStringA" _
( _
ByVal fdwError As Long, _
ByVal lpszErrorText As String, _
ByVal cchErrorText 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

Private mClearVid As Boolean

Private Sub PlayVid(File As String, PBox As PictureBox, Optional Resize As
Boolean, Optional Async As Boolean = True)
Dim ReturnVal As Long

'Ferme le device si déjà ouvert
ClearVid

'Ouvre le fichier avi
ReturnVal = mciSendString("open " & File & " type avivideo alias MyVideo
parent " & PBox.hWnd & " style child", 0&, 0&, 0&)

If ReturnVal = 0 Then
'Positionne la vidéo à (0,0)-(largeur PBox,hauteur PBox)
If Resize Then
ReturnVal = mciSendString("put MyVideo window at 0 0 " & _
(PBox.ScaleWidth / Screen.TwipsPerPixelX) & " " & _
(PBox.ScaleHeight / Screen.TwipsPerPixelY), 0&, 0&, 0&)
Else
ReturnVal = mciSendString("put MyVideo window at 0 0", 0&, 0&,
0&)
End If

If Async Then
'Retient qu'il faudra fermer la video
mClearVid = True

ReturnVal = mciSendString("play MyVideo", 0&, 0&, 0&)
Else
'Joue la video (bloquant)
ReturnVal = mciSendString("play MyVideo wait", 0&, 0&, 0&)

'Ferme la video
ReturnVal = mciSendString("close MyVideo", 0&, 0&, 0&)
End If
Else
MsgBox ErrorString(ReturnVal)
End If
End Sub

Private Function ErrorString(ErrNum As Long) As String
Dim strBuff As String
Const MCIERR_MAX_LEN = 129

strBuff = String$(MCIERR_MAX_LEN, vbNullChar)
If mciGetErrorString(ErrNum, strBuff, MCIERR_MAX_LEN) Then
ErrorString = Left$(strBuff, InStr(1, strBuff, vbNullChar) - 1)
End If
End Function

Private Sub Command1_Click()
PlayVid "c:windowsclock.avi", Picture1, False
End Sub

Private Sub ClearVid()
If mClearVid Then
mciSendString "close MyVideo", 0&, 0&, 0&
mClearVid = False
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
ClearVid
End Sub

--
Picalausa François

"DAN" a écrit dans le message de news:
430880c4$0$21299$
"Jean-Marc" a écrit dans le message de
news: 430830d3$0$10959$
"Microsoft Common Controls-2 5.0"


merci bien,cela fonctionne mais il n'accepte pas les fichiers mpg,as tu
une
solution?
du coup il ne sagit plus du controle mci et je n'ai pas acces au boutons
de controle? coment proceder?


Avatar
DAN
merci,cela fonctionne,il me reste à trouver coment programmer la bare de
défilement .
si tu as une idée?
"Picalausa François" a écrit dans le message de news:
%
Hello,

Pour le contrôle mci, je n'ai pas réussi à affecter un parent, mais par
les API mci on peut le faire comme ceci:
Option Explicit

Private Declare Function mciGetErrorString _
Lib "winmm.dll" _
Alias "mciGetErrorStringA" _
( _
ByVal fdwError As Long, _
ByVal lpszErrorText As String, _
ByVal cchErrorText 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

Private mClearVid As Boolean

Private Sub PlayVid(File As String, PBox As PictureBox, Optional Resize As
Boolean, Optional Async As Boolean = True)
Dim ReturnVal As Long

'Ferme le device si déjà ouvert
ClearVid

'Ouvre le fichier avi
ReturnVal = mciSendString("open " & File & " type avivideo alias
MyVideo parent " & PBox.hWnd & " style child", 0&, 0&, 0&)

If ReturnVal = 0 Then
'Positionne la vidéo à (0,0)-(largeur PBox,hauteur PBox)
If Resize Then
ReturnVal = mciSendString("put MyVideo window at 0 0 " & _
(PBox.ScaleWidth / Screen.TwipsPerPixelX) & " " & _
(PBox.ScaleHeight / Screen.TwipsPerPixelY), 0&, 0&, 0&)
Else
ReturnVal = mciSendString("put MyVideo window at 0 0", 0&, 0&,
0&)
End If

If Async Then
'Retient qu'il faudra fermer la video
mClearVid = True

ReturnVal = mciSendString("play MyVideo", 0&, 0&, 0&)
Else
'Joue la video (bloquant)
ReturnVal = mciSendString("play MyVideo wait", 0&, 0&, 0&)

'Ferme la video
ReturnVal = mciSendString("close MyVideo", 0&, 0&, 0&)
End If
Else
MsgBox ErrorString(ReturnVal)
End If
End Sub

Private Function ErrorString(ErrNum As Long) As String
Dim strBuff As String
Const MCIERR_MAX_LEN = 129

strBuff = String$(MCIERR_MAX_LEN, vbNullChar)
If mciGetErrorString(ErrNum, strBuff, MCIERR_MAX_LEN) Then
ErrorString = Left$(strBuff, InStr(1, strBuff, vbNullChar) - 1)
End If
End Function

Private Sub Command1_Click()
PlayVid "c:windowsclock.avi", Picture1, False
End Sub

Private Sub ClearVid()
If mClearVid Then
mciSendString "close MyVideo", 0&, 0&, 0&
mClearVid = False
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
ClearVid
End Sub

--
Picalausa François

"DAN" a écrit dans le message de news:
430880c4$0$21299$
"Jean-Marc" a écrit dans le message de
news: 430830d3$0$10959$
"Microsoft Common Controls-2 5.0"


merci bien,cela fonctionne mais il n'accepte pas les fichiers mpg,as tu
une
solution?
du coup il ne sagit plus du controle mci et je n'ai pas acces au
boutons
de controle? coment proceder?