Page 1 of 1 1
Topic Options
#201353 - 2011-01-11 04:28 PM ADODB.Stream Fun
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Playing around with ADODB.Stream a bit, I found that you can read ID3v1 TAGS with it.
Using ADODB.Stream you can also write to it. But I leave that for later figuring out, since ID3v1 is pretty useless.
But since people looked for a native way to read and write ID3 without 3rd party objects, I decided to play a bit with it, so here is the Read code.
 Code:
Function ConvertBin($Binary)
  Dim $strChar, $i
  For $i=1 to Len($Binary)
    $strChar = Chr(Asc(SubStr($Binary,$i,1)))
    $ConvertBin = $ConvertBin + $strChar
  Next
EndFunction

Dim $objStream, $strFile, $strTag, $strSongName
Dim $strArtist, $strAlbum, $strYear, $strComment, $strGenre
$strFile = "C:\mp3\somefile.mp3"

;Create the Stream object
$objStream = CreateObject("ADODB.Stream")
$objStream.Type = 1

;Open the stream
$objStream.Open
$objStream.LoadFromFile($strFile)

;Read the last 128 bytes
$objStream.Position = $objStream.size - 128

;Read the ID3 v1 tag info
$strTag = ConvertBin($objStream.Read(3))
If ucase($strTag) = "TAG"
  $strSongName = ConvertBin($objStream.Read(30))
  $strArtist = ConvertBin($objStream.Read(30))
  $strAlbum = ConvertBin($objStream.Read(30))
  $strYear = ConvertBin($objStream.Read(4))
  $strComment = ConvertBin($objStream.Read(30))
EndIf

;Display the results
? "ID3 Tag info for: " + $strFile
? "Artist: " + $strArtist
? "Track: " + $strSongName
? "Album: " + $strAlbum
? "Year: " + $strYear
? "Comment: " + $strComment

$objStream.Close
$objStream = ""

Top
#201356 - 2011-01-11 06:44 PM Re: ADODB.Stream Fun [Re: Arend_]
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
very nice! I have been using a program called mp3tag&rename for years now to keep my mp3 collections tagged properly.
Top
#201361 - 2011-01-12 09:41 AM Re: ADODB.Stream Fun [Re: Bryce]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Ha! me too, I love Tag&Rename as well.
But since I have a vast collection of live albums I wanted to write something myself. Mainly to form a proper database of those concerts.

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 456 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.116 seconds in which 0.094 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org