retrieve the length of an mp3 file?
-
Hi can anybody help me? I need to retrieve the song play length for mp3 files for my program? I'm not concerned about the other ID3 tag information. Just the mp3 song length(aka individual mp3 file play lengths). please help. thanks Mr Oizo
Hello Mr Ozio, I hope the code below helps to retrieve information about MP3 file: Option Explicit Public Type MP3Info Tag As String * 3 Songname As String * 30 Artist As String * 30 Album As String * 30 Year As String * 4 Comment As String * 30 Genre As String * 1 End Type Function MP3GetInfo(strFileName As String) As MP3Info Dim sTemp As String, iFreeFile As Integer On Error GoTo ErrFailed iFreeFile = FreeFile Open strFileName For Binary As iFreeFile With MP3GetInfo Get #1, FileLen(strFileName) - 127, .Tag If Not .Tag = "TAG" Then Debug.Print "No tag for " & strFileName Else Get #1, , .Songname Get #1, , .Artist Get #1, , .Album Get #1, , .Year Get #1, , .Comment Get #1, , .Genre End If End With Close iFreeFile Exit Function ErrFailed: Debug.Print "Error in MP3GetInfo: " & Err.Description Close iFreeFile End Function Thanks, James Smith
James Smith www.componentone.com
-
Hello Mr Ozio, I hope the code below helps to retrieve information about MP3 file: Option Explicit Public Type MP3Info Tag As String * 3 Songname As String * 30 Artist As String * 30 Album As String * 30 Year As String * 4 Comment As String * 30 Genre As String * 1 End Type Function MP3GetInfo(strFileName As String) As MP3Info Dim sTemp As String, iFreeFile As Integer On Error GoTo ErrFailed iFreeFile = FreeFile Open strFileName For Binary As iFreeFile With MP3GetInfo Get #1, FileLen(strFileName) - 127, .Tag If Not .Tag = "TAG" Then Debug.Print "No tag for " & strFileName Else Get #1, , .Songname Get #1, , .Artist Get #1, , .Album Get #1, , .Year Get #1, , .Comment Get #1, , .Genre End If End With Close iFreeFile Exit Function ErrFailed: Debug.Print "Error in MP3GetInfo: " & Err.Description Close iFreeFile End Function Thanks, James Smith
James Smith www.componentone.com
-
Hi can anybody help me? I need to retrieve the song play length for mp3 files for my program? I'm not concerned about the other ID3 tag information. Just the mp3 song length(aka individual mp3 file play lengths). please help. thanks Mr Oizo
Both managed DirectX and the Windows Media Player can give you this info. MDX might be better, I think it will do it without a control being required on a form.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hello Mr Ozio, I hope the code below helps to retrieve information about MP3 file: Option Explicit Public Type MP3Info Tag As String * 3 Songname As String * 30 Artist As String * 30 Album As String * 30 Year As String * 4 Comment As String * 30 Genre As String * 1 End Type Function MP3GetInfo(strFileName As String) As MP3Info Dim sTemp As String, iFreeFile As Integer On Error GoTo ErrFailed iFreeFile = FreeFile Open strFileName For Binary As iFreeFile With MP3GetInfo Get #1, FileLen(strFileName) - 127, .Tag If Not .Tag = "TAG" Then Debug.Print "No tag for " & strFileName Else Get #1, , .Songname Get #1, , .Artist Get #1, , .Album Get #1, , .Year Get #1, , .Comment Get #1, , .Genre End If End With Close iFreeFile Exit Function ErrFailed: Debug.Print "Error in MP3GetInfo: " & Err.Description Close iFreeFile End Function Thanks, James Smith
James Smith www.componentone.com
Assuming this works at all, it looks to me like it reads id3 tags, which don't include length.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )