Results 1 to 7 of 7

Thread: Duration of video file!

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    5

    Duration of video file!

    Hey
    How do I get Visual Basic to find information about a video file, such as its duration? In Windows XP it is easy to find this information by choosing the options for the file - so it must be possible!

    Thank you in anticipation!

  2. #2
    Banned Michael_Kamen's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,180
    Do you mean you want it through code?

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    5

    Duration of video file!

    I am not sure what you mean, but I am coding a program, where I need Visual Basic to know the duration of a video file, so that I can calculate with it!

  4. #4
    Hyperactive Member Simon Caiger's Avatar
    Join Date
    Aug 2000
    Location
    Rugby, England
    Posts
    377
    Yes, this can be done.

    Just a chunk from a large prog I did once

    VB Code:
    1. Set media_control = New FilgraphManager         'Filter controls and properties
    2.    
    3.     iFile = FreeFile
    4.     Open App.Path + "\TempAVI.avi" For Binary As #iFile
    5.         bArr = LoadResData(sMovieToPlay, "CUSTOM") 'change this to reflect the correct ID
    6.         Put #iFile, , bArr
    7.     Close #iFile
    8.  
    9.     media_control.RenderFile (App.Path + "\TempAVI.avi")
    10.     Set media_window = media_control                'Payback window properties and controls
    11.     Set media_position = media_control              'Playback position properties and controls

    The play time is accessed something like

    media_position.StopTime
    Simon Caiger

    Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing.

  5. #5
    Hyperactive Member Simon Caiger's Avatar
    Join Date
    Aug 2000
    Location
    Rugby, England
    Posts
    377
    Oh and you need to use the Quartz.dll
    Simon Caiger

    Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing.

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    5

    Duration of video file!

    Hey I have tried to use the code above, but it wont work. Obvious I'm not that good at VB, so you have to make it very clear what I have to change in the code.

    First of all I can't choose FilgraphManager. I have tried to use the name of my own project, but it "wasn't expected".

    Next VB can't find identifier for sMoviePlay.

  7. #7
    Hyperactive Member Simon Caiger's Avatar
    Join Date
    Aug 2000
    Location
    Rugby, England
    Posts
    377
    Hi,

    Sorry, the chunk of code I posted is just a bit of my program.

    The movies are stored in a resource file in my case and the movie identified by the string "sMovieToPlay" is shown being loaded into a temporary file.

    You could just use

    VB Code:
    1. media_control.RenderFile (App.Path + "\TempAVI.avi")

    to load your .avi

    You need to set a referenve to the "Active Movie Control Type Library in the Project References.

    Hope this helps a bit more.
    At the moment project pressures don't allow me time to put together a working example.

    If you're still stuck let me know and when I have a bit more time, I will post a full example.
    Simon Caiger

    Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width