Solved

how to know the size of a video ?

Posted on 2002-06-19
8
209 Views
Last Modified: 2010-05-02
hello,

I open a video with mediaplayer control in vb6.

I would like to know the real size of the video, is there anyway to do it ?

regards,

oliver
0
Comment
Question by:albundy
  • 4
  • 4
8 Comments
 
LVL 3

Accepted Solution

by:
Elmo_ earned 200 total points
ID: 7095279
Albundy,

This should work for you.

Hope it helps

Cheers,

Ed.

-----------------------------------------------------
'Visual Basic Example - Get File Size
' Example by AKriLium-Death (bumpybl2@hotmail.com)
' Visit his site at http://rift.zeloop.com
'This project needs
' -a Command Button (Command1)
' -a CommonDialog (CommonDialog1)
' -a Label (Label1)
Private Const OF_READ = &H0&
Private Declare Function lOpen Lib "kernel32" Alias "_lopen" ( _
    ByVal lpPathName As String, _
    ByVal iReadWrite As Long _
) As Long

Private Declare Function lclose Lib "kernel32" Alias "_lclose" ( _
    ByVal hFile As Long _
) As Long

Private Declare Function GetFileSize Lib "kernel32" ( _
    ByVal hFile As Long, _
    lpFileSizeHigh As Long _
) As Long

Dim lpFSHigh As Long

Public Sub GetInfoF(FilePath As String)
    Dim Pointer As Long, sizeofthefile As Long
    Pointer = lOpen(FilePath, OF_READ)
    'size of the file
    sizeofthefile = GetFileSize(Pointer, lpFSHigh)
    Label1.Caption = sizeofthefile & " bytes"
    lclose Pointer
End Sub

Private Sub command1_Click()
    CommonDialog1.ShowOpen
    GetInfoF CommonDialog1.filename
End Sub

Private Sub Form_Load()
    With CommonDialog1
        .DialogTitle = "Select a file"
        .Filter = "All the files|*.*"
    End With
    Command1.Caption = "Select a file"
End Sub


0
 

Author Comment

by:albundy
ID: 7095608
hummm... I mean the video size, width x height :)

anyway I founded it on msdn.

thx anway
0
 
LVL 3

Expert Comment

by:Elmo_
ID: 7095747
Albundy,

Could you close out the question anyway please?

It helps with the clean up process.

Also, Could you post your answer as a comment so that If someone else has the same problem they can find the answer quickly?

Thanks

Ed.
0
 

Author Comment

by:albundy
ID: 7096741
you're totally right :) I do it right now ;o)

put this in a module .bas

   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

----------------------------------------------------------

then here is the code : note, you have to add a mci control , mci32.ocx.


Const MB_OK = 0
      Const MB_ICONSTOP = 16

      Dim Retval&, Buffer$
      Dim dwParam2 As MCI_OVLY_RECT_PARMS

      MMControl1.Command = "Close"
      MMControl1.FileName = txt_pat  'Sample AVI file to be
                                               'played.

      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:
         wid = dwParam2.rc.Right - dwParam2.rc.Left
         hei = dwParam2.rc.Bottom - dwParam2.rc.Top
         size= wid & "x" & hei
         'MMControl1.Command = "close"
      End If
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:albundy
ID: 7096755
mmmmm how to close it ? :)
0
 
LVL 3

Expert Comment

by:Elmo_
ID: 7098014
Albundy,

You could ask one of the EE Moderators to accept your comment as the answer.  So if someone is looking for the same solution as yourself they can find it easily.

Cheers,

Ed.
0
 

Author Comment

by:albundy
ID: 7098119
boaaa, I give you the points... nevermind :o)

cheers,
0
 
LVL 3

Expert Comment

by:Elmo_
ID: 7098172
Cheers
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

758 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

20 Experts available now in Live!

Get 1:1 Help Now