Using MCI (vb4-32): Done event and Dynamic Sizing 
Author Message
 Using MCI (vb4-32): Done event and Dynamic Sizing

I am writing a program which plays an .avi in a picture box.  The
relationship is set up as follows:

mciControl.hWndDisplay = picMovieBox.hWnd

There are two problems.  (1) I cannot get picMovieBox to dynamically
fit the .avi image; I have run into a bit of a roadblock with
Knowledge Base solution Q126742, because this applies to VB3.  The
AutoSize property of the picture box does not seem to do the trick.

(2) I should like to execute picMovieBox.Visible = false when the
movie stops playing; but I cannot get the _Done event to execute.  I
have the following code which should trigger (from what I have been
reading) the _Done event:

mciControl.Notify = True
mciControl.Command = "Play"

Thanks in advance.
Regards,

Darcy

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2

mQCNAzE8q3IAAAEEALsnVELQXvnqRgyvdqy15bThZgTkL8uAmuB2OuX3T1Vtq/6I
97NIv9apTrAKbvrWD3Rb+daMUusQQWPOvsdJ4lYECEbvtYtsSVz7R4N3jjyyL2bQ
F/gVcsHErZQ5Z+H5jpHbpiv81Wf3r9Q4K+np75RyqzSCEOGPIVOKQua6HoLdAAUR
tA1LLiBEYXJjeSBPdHRviQCVAwUQMTys5lOKQua6HoLdAQFDeAP/ZNy6MbJXfjZI
Q7pGgdhZsbkLzxioAtwFCmevkFbLPk353/TCI4ekTFLn/a4FOftut1+QhJ890byR
36H3+n1tHoSTCewM+eqGebm9kQRao9pAM802RAIzYJy+sLSwwsi/pB8QpoTKHJjt
GPEuPqrFGm6bfd04WliO960N56UI7CQ=
=mvZP
-----END PGP PUBLIC KEY BLOCK-----



Fri, 01 Jan 1999 03:00:00 GMT  
 Using MCI (vb4-32): Done event and Dynamic Sizing

Quote:

>> (2) I should like to execute picMovieBox.Visible = false when the
>> movie stops playing; but I cannot get the _Done event to execute.  I
>> have the following code which should trigger (from what I have been
>> reading) the _Done event:

>> mciControl.Notify = True
>> mciControl.Command = "Play"

>That should work fine.  Have you stepped through with a de{*filter*} to see
>what is happening ?

I still have the same problem.  When I put a stop in the _Done event,
the program never hits it.  Stepping through reveals that the program
acts normally for the most part; however, sometimes it seems to freeze
because it is playing the .avi.  I am postulating that the system just
forgets to fire the _Done event; is this probable?
Regards,

Darcy

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2

mQCNAzE8q3IAAAEEALsnVELQXvnqRgyvdqy15bThZgTkL8uAmuB2OuX3T1Vtq/6I
97NIv9apTrAKbvrWD3Rb+daMUusQQWPOvsdJ4lYECEbvtYtsSVz7R4N3jjyyL2bQ
F/gVcsHErZQ5Z+H5jpHbpiv81Wf3r9Q4K+np75RyqzSCEOGPIVOKQua6HoLdAAUR
tA1LLiBEYXJjeSBPdHRviQCVAwUQMTys5lOKQua6HoLdAQFDeAP/ZNy6MbJXfjZI
Q7pGgdhZsbkLzxioAtwFCmevkFbLPk353/TCI4ekTFLn/a4FOftut1+QhJ890byR
36H3+n1tHoSTCewM+eqGebm9kQRao9pAM802RAIzYJy+sLSwwsi/pB8QpoTKHJjt
GPEuPqrFGm6bfd04WliO960N56UI7CQ=
=mvZP
-----END PGP PUBLIC KEY BLOCK-----



Mon, 04 Jan 1999 03:00:00 GMT  
 Using MCI (vb4-32): Done event and Dynamic Sizing


Quote:
>I am writing a program which plays an .avi in a picture box.  The
>relationship is set up as follows:

>mciControl.hWndDisplay = picMovieBox.hWnd

>There are two problems.  (1) I cannot get picMovieBox to dynamically
>fit the .avi image; I have run into a bit of a roadblock with
>Knowledge Base solution Q126742, because this applies to VB3.  The
>AutoSize property of the picture box does not seem to do the trick.

Just following up my own question with the solution I have found to
the first problem.  Here is the code:

'----------------------------------------------------------------
'The following routine is modified from an article by Simon
'Bernstein (thanks Simon!) and Knowledge Base article
'Q126742.  I don't know the ins and outs, but have documented
'things where I could.  Basically it gets the .avi size before it
'plays, and sizes the picture box appropriately.
'----------------------------------------------------------------

Dim mciRect As MCI_DGV_RECT_PARMS
Dim lRet As Long
Dim sAlias As String
Dim sTemp As String

'----------------------------------------------------------------
'Generate a unique alias.
'----------------------------------------------------------------
sAlias = Trim$(Str$(GetTickCount()))

'----------------------------------------------------------------
'Open the .avi file with the alias.
'----------------------------------------------------------------
sTemp = "Open " & sAvi & " Alias " & sAlias
lRet = mciSendString(sTemp, 0&, 0, 0)
If lRet <> 0 Then
    Call Error("Error Opening AVI", sTemp, True)
End If

'----------------------------------------------------------------
'Set up the device to work correctly.
'----------------------------------------------------------------
mciMovie.DeviceID = mciGetDeviceID(sAlias)
sTemp = "Window " & sAlias & " Handle " &
Trim$(Str$(picMovieBox.hWnd))
lRet = mciSendString(sTemp, 0&, 0, 0)

'----------------------------------------------------------------
'Get the current rectangle of the .avi.
'----------------------------------------------------------------
Call mciSendCommand(mciMovie.DeviceID, MCI_WHERE,
MCI_DGV_WHERE_SOURCE, mciRect)

'----------------------------------------------------------------
'If you want to stretch the .avi to a certain size at this point,
'you can scale it with the following commands:
'
'mciRect.rc.right = <width>
'mciRect.rc.bottom = <height>
'
'Both <width> and <height> are in pixels; if you want to double
'or half the size, &c, simply use .right = .right * 2, &c.
'----------------------------------------------------------------

'----------------------------------------------------------------
'Now build the command string.
'----------------------------------------------------------------
sTemp = "Put " & sAlias & " Destination at " & mciRect.rc.Left & " " &
mciRect.rc.Top & " " & mciRect.rc.Right & " " & mciRect.rc.Bottom
lRet = mciSendString(sTemp, 0&, 0, 0)
If lRet <> 0 Then
    Call Error("Error Sizing AVI", sTemp, True)
End If

'----------------------------------------------------------------
'The movie will appear in picMovieBox, so specify its dimensions.
'Don't forget that mciRect.rc.~ is in pixels, so you have to
'multiply it by 15 if you want to get twips.
'----------------------------------------------------------------
With picMovieBox
    .Height = (mciRect.rc.Bottom - mciRect.rc.Top) * 15
    .Width = (mciRect.rc.Right - mciRect.rc.Left) * 15
    .Top = Screen.Height \ 2 - .Height \ 2
    .Left = Screen.Width \ 2 - .Width \ 2
    .Visible = True
End With

'----------------------------------------------------------------
'Play the sucker.
'----------------------------------------------------------------
mciMovie.Notify = True
mciMovie.Command = "Play"

Don't forget to put declarations in your General/Declarations section:

Declare Function mciSendCommand Lib "winmm" Alias "mciSendCommandA" (
_
    ByVal udeviceid As Long, _
    ByVal uMessage As Long, _
    ByVal dwParam1 As Long, _
    dwParam2 As Any) As Long

Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" ( _
    ByVal lpstrCommand As String, _
    ByVal lpstrReturnString As Any, _
    ByVal uReturnLength As Integer, _
    ByVal hWndCallback As Integer) As Long

Declare Function mciGetDeviceID Lib "winmm" Alias "mciGetDeviceIDA" (
_ ByVal lpstrName As String) As Integer

Declare Function GetTickCount Lib "kernel32" () As Long

Public Const MCI_PUT = &H842
Public Const MCI_WHERE = &H843
Public Const MCI_DGV_WHERE_SOURCE = &H20000
Public Const MCI_DGV_WHERE_DESTINATION = &H40000
Public Const MCI_DGV_PUT_DESTINATION = &H40000

Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Type MCI_DGV_RECT_PARMS
    dwCallback As Long
    rc As RECT
End Type

Regards,

Darcy

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2

mQCNAzE8q3IAAAEEALsnVELQXvnqRgyvdqy15bThZgTkL8uAmuB2OuX3T1Vtq/6I
97NIv9apTrAKbvrWD3Rb+daMUusQQWPOvsdJ4lYECEbvtYtsSVz7R4N3jjyyL2bQ
F/gVcsHErZQ5Z+H5jpHbpiv81Wf3r9Q4K+np75RyqzSCEOGPIVOKQua6HoLdAAUR
tA1LLiBEYXJjeSBPdHRviQCVAwUQMTys5lOKQua6HoLdAQFDeAP/ZNy6MbJXfjZI
Q7pGgdhZsbkLzxioAtwFCmevkFbLPk353/TCI4ekTFLn/a4FOftut1+QhJ890byR
36H3+n1tHoSTCewM+eqGebm9kQRao9pAM802RAIzYJy+sLSwwsi/pB8QpoTKHJjt
GPEuPqrFGm6bfd04WliO960N56UI7CQ=
=mvZP
-----END PGP PUBLIC KEY BLOCK-----



Tue, 05 Jan 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Common Dialog and Timer Events/MCI Done Event

2. HELP! MCI in VB4-16/32

3. Problem with Multimedia MCI Cotrol in VB4-32 bit

4. MCI Visibilty & StatusUpdate (VB4-32)

5. VB4-32, create dynamic menu's ?

6. VB4-32, create dynamic menu's ?

7. VB4-32, create dynamic menu's ?

8. MCI done event

9. MCI control doesn't generate DONE Event

10. MCI Control Gets Into a Tizzy - Done Events Not Being Generated

11. Capturing undefined events in VB4 32-bit

12. VB4 32-bit Timer Event Problems

 

 
Powered by phpBB® Forum Software