SDBAlbumArtList.AddNew only adds one artwork per script run

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

Moderators: Gurus, Addon Administrators

rivorson
Posts: 594
Joined: Thu Jul 25, 2013 4:17 am

SDBAlbumArtList.AddNew only adds one artwork per script run

Post by rivorson »

I'm trying to write a script which adds artwork to multiple tracks but I have found that only one artwork can be added per script call.

The following code runs successfully on multiple tracks but only the last track in SelectedSongList receives the artwork. Artwork in all tracks before the last track remain unchanged.

Code: Select all

Set tracklist = SDB.SelectedSongList
For i = 0 To tracklist.Count - 1
	Set NewArt = tracklist.Item(i).AlbumArt.AddNew
	NewArt.ItemStorage = 1
	NewArt.PicturePath = "C:\testart.jpg"
Next 'i
tracklist.UpdateAll
If I move the location of the instruction to update the database into the For loop then the result is slightly different. In the following code the first track receives the new artwork and all subsequent tracks are unchanged.

Code: Select all

Set tracklist = SDB.SelectedSongList
For i = 0 To tracklist.Count - 1
	Set NewArt = tracklist.Item(i).AlbumArt.AddNew
	NewArt.ItemStorage = 1
	NewArt.PicturePath = "C:\testart.jpg"
	tracklist.Item(i).UpdateDB
Next 'i

This is a very simplified version of the code. In the full code every track should receive a unique artwork instead of all receiving the same file, but the result is the same. Is there something that I'm doing wrong?


MMW 1821 running on Windows 10.
rivorson
Posts: 594
Joined: Thu Jul 25, 2013 4:17 am

Re: SDBAlbumArtList.AddNew only adds one artwork per script

Post by rivorson »

Slight update. It isn't necessarily the first or the last item in the track list that is updated but rather the single active track in view, i.e. the track at the cursor position.

I tried changing to AllVisibleSongList and running with nothing selected. Only the active track in the track list has its artwork updated.

Further, when I changed my 'Art & Details' window from displaying 'Selected' to displaying 'Now Playing' the script stopped updating any artwork in the selected track list. It seems that the script can only update artwork for the track that is currently displayed in the 'Art & Details' window.
Post Reply