![]() |
![]() |
|
![]() |
Using the Alfafish MP3 tag reader/writer ActiveX control in Paradox © 2001 Peter Zevenaar Introduction At the moment MP3 is the standard for digital music. It is an abbreviation for MPEG audio layer 3. The MP3 format uses an outstanding compression technique which can reduce a .WAV file's size by a factor of 10 while the sound quality remains very good. In the early days of MP3 it wasn't possible to include textual information in the files. The only way to add info to an MP3 was to put it in its actual filename. So they created the MP3 tag. The first was called ID3 v1.1 and includes the possibility to store the title, artist, album, year, genre, a comment field, and a field that says which CD the music originates from. However, the size of those fields is only 30 characters. That's why a new ID3 tag was created: ID3v2. It is currently in a state of 'informal standard' and supports an almost unlimited number of characters in its tag fields. Further it supports Unicode so you can always write in your native language. Find out more about MP3 and MP3 tags at these links: http://www.mpeg.org/MPEG/mp3.html#overview http://id3.org/easy.html Free Alfafish EzyID3 3.0 beta 2 ActiveX control Standard Paradox can't read or write MP3 tags but with the use of an ActiveX control it can. I found that the free Alfafish EzyID3 3.0 beta 2 ActiveX control, originally written for use with Microsoft's Visual Basic, works well in Paradox 10, with a workaround though. I tested EzyID3 in Paradox 8 as well but couldn't get it to work. There might be other MP3 tag readers/writers that work in Paradox as well. If you know of any, or you have comments about or items to add to this article, please send them to Paradox Community's submissions editor. What does EzyID3 3.0 do?
![]() http://www.alphafish.com/core.php?page=article&id=3 "Beta doesn't mean 'buggy and crashing a lot', but rather that the ID3v2 standard isn't implemented yet to it's full extent", as stated by Erik Christiansson, the creator of EzyID3 3.0 beta 2. In my Music Archive v1.2 application I've found EzyID3 3.0 to be very effective. The fact that it can't write field values larger than 30 characters isn't so much an issue for me, although it would be nice. For a case study on Music Archive click here. Implementing EzyID3 in your Paradox application Once you've downloaded EzyID3 you don't have to run the install file. You only need to copy the file named AlfafishEzyID33vb6.ocx (which is in the zip file) to the desired directory and register it. For further basic instructions on ActiveX controls ready for use in Paradox, go to ActiveX controls - A step by step tutorial. For my Music Archive application I only needed to read and write MP3 tags so that's what I focused on. EzyID3 offers other options as well which I haven't explored yet. For reading and writing the MP3 tags here are the most important methods and properties in the EzyID3 ActiveX control: Methods: read(), save()Note: There are more methods and properties available in EzyID3. Check them out in the EzyID3 ActiveX with the Object Explorer. Putting EzyID3 to work is not hard. Follow these two simple examples. To work with these examples in runtime you have to put a valid path and MP3 filename in fldFileName. Example 1: Read MP3 tag First we want to read an MP3's tag and MPEG info. Once you have EzyID3 on your ActiveX toolbar, you can click-and-drag it on a new form and name it EzyID3ocx. Then you are able to access it in with ObjectPAL code. Put nine undefined fields on your form and name them fld + the EzyID3 property's name as listed above. Note: the "fld" - addition is especially important for the EzyID3's Filename property as Filename is a reserved word in Paradox. Place a pushbutton() named Read MP3 on your form and paste the following code in it: method pushButton(var eventInfo Event) var totalseconds LongInt totaltime Time endvar ;// Empty all the fields in the form to make sure the ;// fields won't get values of the previously read MP3 ;// when one or more of the currently read MP3 values ;// is not present. fldArtist.value="" fldSong.value="" fldLength.value="" fldAlbum.value="" fldYear.value="" fldComment.value="" fldGenre.value="" ;// In runtime, after you typed the right filename ;// including its path in the fldFileName field, we ;// give the ActiveX control property Filename the ;// value of the filename you just typed. EzyID3ocx.filename = fldFileName.value ;// Now we read the MP3 tag and MPEG info into the ;// ActiveX control. We use Try-Onfail-Endtry. If-Endif ;// doesn't work in this respect since EzyID3 doesn't ;// report if the method had been executed True or False. ;// See the paragraph "Important: Workaround" ;// for handling errors. try EzyID3ocx.read() onfail msgStop("Error","Can't read tag of "+fldFileName.value) errorshow() return endtry ;// 'Copy' the ActiveX's properties values ;// to the form's fields. fldArtist.value=EzyID3ocx.artist fldSong.value=EzyID3ocx.song fldAlbum.value=EzyID3ocx.album fldYear.value=EzyID3ocx.year fldComment.value=EzyID3ocx.comment fldGenre.value=EzyID3ocx.genre ;// An MP3's song length is stored as the number of ;// seconds. This code from Rick Kelly converts the ;// number of seconds to a time value totalSeconds = EzyID3ocx.Length totalTime = time(totalSeconds * 1000) fldLength.value=TotalTime endMethodExample 2: Write MP3 tag Now we want to write an MP3's tag. Let's assume that after you read the MP3's tag as described in example 1, you made changes for instance in the fldYear and fldSong fields. You want to save those changes to the MP3's tag. Put another pushbutton() named Write MP3 on your form and paste the following code in it: method pushButton(var eventInfo Event) ;// We 'copy' the (changed) field values to the ;// EzyID3's properties thus replacing the old values. EzyID3ocx.artist=fldArtist.value EzyID3ocx.song=fldSong.value EzyID3ocx.album=fldAlbum.value EzyID3ocx.year=fldYear.value EzyID3ocx.comment=fldComment.value EzyID3ocx.genre=fldGenre.value ;// Now we save the MP3 tag. try EzyID3ocx.save() onfail msgStop("Error","Can't save "+OCXfileName.value+"'s tag") errorshow() return endtry endMethodNote: If you made changes in the Artist name or Song name, you may want to change the MP3's filename accordingly, something EzyID3 won't let you do. But you can do it with Paradox's file system rename() method. Workaround: Important! There's one bug in EzyID3's internal code that needs to be taken into account. If an MP3 file can't be opened or saved by the ActiveX control, for instance because the MP3 file isn't there, you'll get an error message and the ActiveX control hangs. If you try to repeat the action, sometimes Paradox will hang too. There is a clear() method in the ActiveX control but that doesn't work to make EzyID3 available again after hanging . To avoid the annoying behavior of EzyID3 hanging, I made a workaround, which works well. I put the ActiveX control on a separate (hidden) form and do the reading and writing of the MP3 tag there by calling the form from my main form. If there's an error with the ActiveX control, the form and the ActiveX control are closed and opened again from the calling form. This makes the EzyID3 ready to use again. Opening and closing the form and with that the ActiveX, happens very quickly so you don't notice it. Discussion of this article |
![]() Feedback | Paradox Day | Who Uses Paradox | I Use Paradox | Downloads ![]() |
|
![]() The information provided on this Web site is not in any way sponsored or endorsed by Corel Corporation. Paradox is a registered trademark of Corel Corporation. ![]() |
|
![]() Modified: 26 May 2003 Terms of Use / Legal Disclaimer ![]() |
![]() Copyright © 2001- 2003 Paradox Community. All rights reserved. Company and product names are trademarks or registered trademarks of their respective companies. Authors hold the copyrights to their own works. Please contact the author of any article for details. ![]() |
![]() |
|