SDBAlbumArtList.AddNew only adds one artwork per script run

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

Moderator: Gurus

SDBAlbumArtList.AddNew only adds one artwork per script run

Postby rivorson » Tue Dec 27, 2016 11:29 am

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: 526
Joined: Thu Jul 25, 2013 4:17 am

Re: SDBAlbumArtList.AddNew only adds one artwork per script

Postby rivorson » Tue Dec 27, 2016 11:56 am

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.
rivorson
 
Posts: 526
Joined: Thu Jul 25, 2013 4:17 am


Return to MediaMonkey 4 Addons developer forum

Who is online

Users browsing this forum: No registered users and 4 guests