Solved

AVI Files

Posted on 1998-09-11
6
335 Views
Last Modified: 2012-06-22
How can i play an AVI file in vb5, but i want the image to appear in my own location, without the MCI control to apperar. ie. My own control buttons,play,stop,pause
0
Comment
Question by:abidsml
  • 3
  • 2
6 Comments
 
LVL 12

Accepted Solution

by:
mark2150 earned 10 total points
ID: 1434392
Turn off all of the buttons on the MCI object. This will give you a "naked" picture frame. Add your objects on the form and set them to issue the appropriate MCI commands when clicked. This will give you full AVI functionality with your own "look & feel".

IMHO tho, this will get your software panned for a "non standard" UI. But, I can see there would be times when your own controls would be handy (or even NO controls).

0
 

Author Comment

by:abidsml
ID: 1434393
just how can i view the animation in my own picture box in this case?
0
 

Author Comment

by:abidsml
ID: 1434394
can u please sending a sample code on a form contain a picture box to view the file in it.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:mark2150
ID: 1434395
You can't put the picture in your *own* picture box, you still have to have the MCI control box for playback, but you can align it so it *looks* just like your picture box and it'll have no borders to mess things up.

I use ActiveMovie control and set ShowControls, ShowDisplay, ShowPositionControls, ShowSelectionControls, ShowTracker properties to False. Then when I need to "roll tape" I simply code:

Public movieover As Boolean
Public imready As Boolean
Public AtEnd As AMovieCtl.StateConstants
Public rs As AMovieCtl.ReadyStateConstants
.

' This fires the movie:
'
    Call showmovie("EXCEL.AVI")
.
Public Sub showmovie(moviename As String)
    Dim movie As String
    movie = ourdir & moviename
    ActiveMovie1.filename = movie
    Do While Not movieover
        DoEvents
    Loop
    Me.Refresh
    Me.SetFocus
End Sub

The above plays the movie and waits for it to complete before proceeding

Support routines include:

 Private Sub ActiveMovie1_StateChange(ByVal oldState As Long, ByVal newState As Long)
   If newState = amvStopped Then
     ActiveMovie1.Visible = False
     movieover = True
   End If
   '
End Sub

Private Sub ActiveMovie1_ReadyStateChange(ReadyState As AMovieCtl.ReadyStateConstants)
'
   If ReadyState = amvComplete Or ReadyState = amvInteractive Then
      ' It's ready to run.
    ActiveMovie1.Visible = True
     ActiveMovie1.Run
     movieover = False
   End If
'
End Sub
'
' Ensure movie is off at load time
'
Private Sub Form_Activate()
ActiveMovie1.Visible = False
ActiveMovie1.Stop
End Sub

0
 

Author Comment

by:abidsml
ID: 1434396
thanks, i will try this
0
 

Expert Comment

by:cameron2
ID: 1434397
This will make it so that you can view files within your form using command buttons

Step-by-Step Example
--------------------

1. Start a new project in Visual Basic. Add a module (.BAS) file, and make
   sure the MCI control is included in the project. Add a MCI control
   (MMControl1), a Command Button (Command1), and a Picture box (Picture1)
   to Form1. Set Form1's ScaleMode property to Pixels (3).

2. In the General declarations section of the .BAS file, add this code:

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

   Type MCI_OVLY_RECT_PARMS
      dwCallback As Long
      rc As RECT
   End Type

   Global Const MCI_OVLY_WHERE_SOURCE = &H20000
   Global Const MCI_OVLY_WHERE_DESTINATION = &H40000
   Global Const MCI_WHERE = &H843

   'Enter the following Declare statement:
   Declare Function mciSendCommand Lib "winmm.dll" _
      Alias "mciSendCommandA" ( _
         ByVal wDeviceID As Long, _
         ByVal uMessage As Long, _
         ByVal dwParam1 As Long,
         dwParam2 As Any) As Long

   ' Enter the following Declare statement:
   Declare Function mciGetErrorString Lib "winmm.dll" _
      Alias "mciGetErrorStringA" ( _
         ByVal dwError As Long, _
         ByVal lpstrBuffer As String, _
         ByVal uLength As Long) As Long

3. In the Command1_Click() method for the Command button on Form1, enter
   this code:

   Sub Command1_Click ()
      Const MB_OK = 0
      Const MB_ICONSTOP = 16

      Dim Retval&, Buffer$
      Dim dwParam2 As MCI_OVLY_RECT_PARMS

      MMControl1.Command = "Close"
      MMControl1.Filename = "WndSurf1.avi"  'Sample AVI file to
                                            'played.

      'Get the MCI control to display the video in Picture1:
      MMControl1.hWndDisplay = Picture1.hWnd

      MMControl1.Command = "Open"

      'Initialize the structure being passed with mciSendCommand, and
      'set it in case you want to use the Notify property:
      dwParam2.dwCallback = MMControl1.hWnd
      dwParam2.rc.Left = 0
      dwParam2.rc.Top = 0
      dwParam2.rc.Right = 0
      dwParam2.rc.Bottom = 0

      'Send the message:
      'Enter the following two lines as one, single line of code:
      Retval& = mciSendCommand(MMControl1.DeviceID, MCI_WHERE,
                MCI_OVLY_WHERE_SOURCE, dwParam2)

      If Retval& <> 0 Then  ' An error occurred.
         Buffer$ = Space$(100)
         'Get a description of the error:
         Retval& = mciGetErrorString(Retval&, Buffer$, Len(Buffer$))
         MsgBox Trim$(Buffer$), MB_OK + MB_ICONSTOP, "ERROR"
      Else
         'Resize the picture box:
         Picture1.Width = dwParam2.rc.right - dwParam2.rc.left
         Picture1.Height = dwParam2.rc.bottom - dwParam2.rc.top

         'Play the video:
         MMControl1.Wait = True ' Wait for the next command to complete
         MMControl1.Command = "play" 'Play the video clip
         MMControl1.Command = "close"
      End If
   End Sub

4. Test the program by pressing the F5 key to run it, and clicking the
   command button. The AVI file will play back in the picture box, which
   will have been resized to fit the video clip exactly.

Additional reference words: 3.00 4.00 MCI AVI vb4win vb432
KBCategory: kbprg kbcode kbhowto
KBSubcategory: APrgWindow


Make the mci buttons not visible by going to the properties and scroll down until you find visible change it to false





0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now