Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. retrieve the length of an mp3 file?

retrieve the length of an mp3 file?

Scheduled Pinned Locked Moved Visual Basic
helpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Oizo
    wrote on last edited by
    #1

    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

    J C 2 Replies Last reply
    0
    • M Mr Oizo

      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

      J Offline
      J Offline
      JamesS C1
      wrote on last edited by
      #2

      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

      M C 2 Replies Last reply
      0
      • J JamesS C1

        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

        M Offline
        M Offline
        Mr Oizo
        wrote on last edited by
        #3

        Half that code doen't run.I think thats like vb6 or something. Dunno. I'll try change it a bit but I'm really looking to just get the mp3file play time length(song length)? What line or 2 do I use:doh: thanks for the reply Mr Oizo

        1 Reply Last reply
        0
        • M Mr Oizo

          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

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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 )

          1 Reply Last reply
          0
          • J JamesS C1

            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

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            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 )

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups