getTemporaryCopy parameter count

To discuss development of addons / skins / customization of MediaMonkey.

Moderator: jiri

getTemporaryCopy parameter count

Postby TIV73 » Sun Oct 01, 2017 3:53 pm

Hi everybody,
it looks like (one of) the latest public revision(s) changed how getTemporaryCopy works. Previously, I could do something like this:
Code: Select all
var currentTrack = app.player.getCurrentTrack();
var copy = currentTrack.getTemporaryCopy();

Now I'm just getting a wrong parameter count error when trying that. Other than this, which doesn't say anything about any parameters I couldn't find any examples or documentation, so I'm a bit lost on how to use the function.
I suppose I could use getTemporaryCopies instead, but wrapping a track it in a tracklist, making a copy of said list and finally extracting a copy of the original track seems kinda hacky if I only have one track to begin with.

So, does anybody have any hints on how to use getTemporaryCopy or any other method to copy a track object that doesn't just return a reference to the original object but actually creates a new one?

Having a look at my original function, maybe I'm overthinking this:

Code: Select all
if (track.artist !== newArtist) {
   let newTrack = track.getTemporaryCopy()
   newTrack.artist = newArtist

I wrote this some time ago, so I probably just copied it from some example I found. Is there any actual benefit to cloning the object, changing a single property and then assigning the copy back to the original - I mean as opposed to just changing the property? It's probably handy if you change a couple of attributes and want to avoid having to compare every single property to update the original object, but in this case it's maybe just a waste of resources.

Edit 2:
Yes, just assigning a new value to track.artist works fine and doesn't have any negative side effects (that I could find), so I'll just use that. Out of curiosity I sill wonder how getTemporaryCopy should be used, though.
Posts: 46
Joined: Sat Nov 12, 2011 1:31 pm

Re: getTemporaryCopy parameter count

Postby PetrCBR » Mon Oct 02, 2017 12:16 am

Hi. It's regression ... thanks for the report.
Posts: 1361
Joined: Tue Mar 07, 2006 5:31 pm
Location: Czech

Re: getTemporaryCopy parameter count

Postby TIV73 » Mon Oct 02, 2017 5:49 am

I didn't think about that option. Thanks a lot for letting me know!
Posts: 46
Joined: Sat Nov 12, 2011 1:31 pm

Return to MediaMonkey 5 developer forum

Who is online

Users browsing this forum: No registered users and 1 guest