Getting SongData members at run time

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

Teknojnky
Posts: 5533
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Getting SongData members at run time

Post by Teknojnky » Wed Jan 07, 2009 12:41 pm

Something that always bugged me that I never figured out, was if/how it would be possible to get all the songdata fields dynamically at run time, instead of coding for each individual field.

Basically, I want to get a (indexed?) list of fields, perform a search, make a change, or check for certain data types on each field (or only specific ones), then move to the next songdata item.

Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Re: Getting SongData members at run time

Post by Bex » Wed Jan 07, 2009 1:00 pm

You have to create your own function which takes a songdata object and the returns all properties as an array. You can then do stuff with the array.

E.g.

Code: Select all

Sub GetAllProperties(SongdataObj)
  Dim AllPropArray(?)
  AllPropArray(0)=SongdataObj.Artist
  AllPropArray(1)=SongdataObj.Title
  AllPropArray(2)=SongdataObj.Album
  A.s.o. to
  AllPropArray(?)=SongdataObj.???

  GetAllProperties=AllPropArray
End Function
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts

Teknojnky
Posts: 5533
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Re: Getting SongData members at run time

Post by Teknojnky » Wed Jan 07, 2009 1:23 pm

but that is the same as coding for each field.

What if you did not know the fields? Yes I know they are documented, but from a programtic point of view?

Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Re: Getting SongData members at run time

Post by Bex » Wed Jan 07, 2009 1:36 pm

Yes, but you can use it multiple times and also save the code for other scripts as well. There is no automated way to retrieve this.
It would be nice though with some auto functions that returns an Arrays consisting of e.g.
All fields (get/let or get)
Editable fields (get/let)
non-editable fields (get)

But for now you need to create them manually. I believe that both Steegy and Trixmoto has made such functions in a couple of their scripts. I have a similar one which I use in ADFF's Copy/Paste Metadata.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts

Post Reply