BASIC

Author Topic: Read out the ID3 of a MP3!  (Read 7871 times)

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5013
  • O Rly?
    • View Profile
Read out the ID3 of a MP3!
« on: 2009-Jan-02 »
Hey if you need to read out the ID3 for a mp3 to get the name, album, year ...

You can use this:

Code: GLBasic [Select]
FUNCTION GetID3: file$, BYREF title$, BYREF artist$, BYREF album$, BYREF year$, BYREF comment$, BYREF genre$
DIM bytearray%[128]
LOCAL check_tag$
OK = OPENFILE(0, file$, TRUE)
       
        IF OK
                FILESEEK 0, -128, -1
                FOR i = 0 TO 127
                        READBYTE 0, bytearray[i]
                NEXT
                CLOSEFILE 0
        ENDIF
       
       
        // Read TAG
        FOR i = 0 TO 2
                check_tag$ = check_tag$ + CHR$(bytearray[i])
        NEXT
       
       
        IF check_tag$ = "TAG"
                // Read title
                FOR i = 3 TO 32
                        title$ = title$ + CHR$(bytearray[i])
                NEXT
                // Read artist
                FOR i = 33 TO 62
                        artist$ = artist$ + CHR$(bytearray[i])
                NEXT
                // Read album
                FOR i = 63 TO 92
                        album$ = album$ + CHR$(bytearray[i])
                NEXT
                // Read year
                FOR i = 93 TO 96
                        year$ = year$ + CHR$(bytearray[i])
                NEXT
                // Read comment
                FOR i = 97 TO 126
                        comment$ = comment$ + CHR$(bytearray[i])
                NEXT
                // Read genre
                genre$ = CHR$(bytearray[127])
        ENDIF
ENDFUNCTION
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10695
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Read out the ID3 of a MP3!
« Reply #1 on: 2009-Jan-03 »
Veeeery usefull. Should be moved to "snippets", no?

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5013
  • O Rly?
    • View Profile
Read out the ID3 of a MP3!
« Reply #2 on: 2009-Jan-03 »
OK :D
I <3 DGArray's :D

PC:
AMD RYzen 7 1700 @3.9Ghz, 16GB HyperX Fury 2666Mhz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard