Gigatrappeur
Messages postés226Date d'inscriptionlundi 6 mai 2013StatutMembreDernière intervention 3 juillet 2014
-
3 juin 2008 à 11:28
Gigatrappeur
Messages postés226Date d'inscriptionlundi 6 mai 2013StatutMembreDernière intervention 3 juillet 2014
-
6 juin 2008 à 09:29
Salut à tous,
J'aimerais récupérer la durée d'un fichier audio ou video.
j'ai trouvé pas mal de codes mais il sont géneralement en vb6 !
Es-ce que quelqu'un sait comment faire ?
Gigatrappeur
Messages postés226Date d'inscriptionlundi 6 mai 2013StatutMembreDernière intervention 3 juillet 20141 6 juin 2008 à 09:29
Salut à tous,
Voici UN code qui permet de récupérer la durée d'un fichier avi en VB .NET (2005) :
Private Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Function GetAviDuration(ByVal sPath As String) As String
' retourne la durée du fichier AVI en secondes
Dim temps As Integer, h As Integer, m As Integer, r As Integer, s As Integer
Dim sAlias As String, sBuffer As String, str_temps As String, heu As String, min As String, sec As String
Dim lRet As Long
sAlias = "FONCTION_MCI_" '& CStr(Now.Second)
' chargement
Call mciExecute("OPEN " & sPath & " TYPE AVIVIDEO ALIAS " & sAlias & " STYLE POPUP")
Dim i As Integer = Len(sPath)
' on récupère les ms totales
sBuffer = New String(vbNullChar, 128&)
Call mciSendString("SET " & sAlias & " TIME FORMAT MS", sBuffer, Len(sBuffer), 0&)
lRet = mciSendString("STATUS " & sAlias & " LENGTH", sBuffer, Len(sBuffer), 0&)