PlayAVIVideoOFF – Play only the audio track of an AVI file

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 LongPrivate Declare Function mciGetErrorString Lib "winmm" Alias _    "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, _    ByVal uLength As Long) As LongPrivate Declare Function GetShortPathName Lib "kernel32" Alias _    "GetShortPathNameA" (ByVal lpszLongPath As String, _    ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long' Play the audio track of an AVI file.' FileName is a string containing the full path of the file.Sub PlayAVIVideoOFF(FileName As String)    Dim RetVal As Long    Dim CommandString As String    Dim ShortFileName As String * 260    Dim deviceIsOpen As Boolean    ' Retrieve short file name format    RetVal = GetShortPathName(FileName, ShortFileName, Len(ShortFileName))    FileName = Left$(ShortFileName, RetVal)        ' Open the device    CommandString = "Open " & FileName & " type avivideo alias AVIFile"    RetVal = mciSendString(CommandString, vbNullString, 0, 0&)    If RetVal Then GoTo error        ' remember that the device is now open    deviceIsOpen = True        ' Set video OFF    CommandString = "Set AVIFile video off"    RetVal = mciSendString(CommandString, vbNullString, 0, 0&)    If RetVal Then GoTo error        ' Play the file    CommandString = "Play AVIFile wait"    RetVal = mciSendString(CommandString, vbNullString, 0, 0&)    If RetVal Then GoTo error        ' Close the device    CommandString = "Close AVIFile"    RetVal = mciSendString(CommandString, vbNullString, 0, 0&)    If RetVal Then GoTo error    Exit Sub    error:    ' An error occurred.    ' Get the error description    Dim ErrorString As String    ErrorString = Space$(256)    mciGetErrorString RetVal, ErrorString, Len(ErrorString)    ErrorString = Left$(ErrorString, InStr(ErrorString, vbNullChar) - 1)    ' close the device if necessary    If deviceIsOpen Then        CommandString = "Close AVIFile"        mciSendString CommandString, vbNullString, 0, 0&    End If    ' raise a custom error, with the proper description    Err.Raise 999, , ErrorStringEnd Function

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS