Results 1 to 5 of 5

Thread: [RESOLVED] How to get Audio Duration.

  1. #1

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Resolved [RESOLVED] How to get Audio Duration.

    Hi everyone!


    How can I get the duration of an audio file without using a WMP?


    - zynder

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: How to get Audio Duration.

    VB Code:
    1. Private Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
    2. Dim FileName As String
    3.  
    4. Private Sub Form_Load()
    5. Dim RetString As String * 256
    6.  
    7.     FileName = "D:\Family\LG\in_the_end.mid"
    8.    
    9.     mciSendString "Open " & FileName & " alias SoundFile", vbNullString, 0, 0&
    10.     mciSendString "Set SoundFile time format milliseconds", vbNullString, 0, 0&
    11.     mciSendString "Status SoundFile length", RetString, Len(RetString), 0&
    12.     MsgBox CLng(RetString) & " milliseconds"
    13.     mciSendString "Close SoundFile", vbNullString, 0, 0&
    14.  
    15. End Sub

    Or alternatively you could use the MCI control

  3. #3

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: How to get Audio Duration.

    Thanks Andrew for the reply! I will try that out. It looks promising.

    Another question. What is an MCI control? Sorry i'm not familiar with this control.

  4. #4
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: [RESOLVED] How to get Audio Duration.

    Its the 'Microsoft Media control'.
    The Multimedia control allows you to manage Media Control Interface (MCI) devices. These devices include: sound boards, MIDI sequencers, CD-ROM drives, audio players, videodisc players, and videotape recorders and players.

  5. #5

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: [RESOLVED] How to get Audio Duration.

    Ok. Thanks!

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