by MPG » Wed Dec 15, 2021 10:37 am
Hi,
I tried for a couple of hours to get the following code to work, however, I keep having problems. The last section is based off Ludek's suggestion and I end up with one of the following problems:
1) if I leave the whenloaded as suggested, the code never falls into the modifyAsync.
2) if I remove the whenloaded, it works just fine sometimes. Sometimes MM just hangs
3) If one of the covers is a link to a file and the file is deleted from the hard drive (not through the MM interface), MM hangs.
When MM hangs, I've noticed that if I attempt to close MM by clicking the "X" on the image in the taskbar, the track property window shows up. So it's like MM is waiting for a response to the property window, but I can't get focus to it.
Any help you can provide, I'd appreciate it.
Code: Select all
function removeAll() {
var blnFrontFound = false;
var intCnt = 0;
var cvr;
var cvrList;
trackList.forEach(function (track){
track.coverList.locked(function () {
//find first cover identified as the front (if any)
for(intCnt=0; intCnt < track.coverList.count; intCnt++){
cvr = track.coverList.getValue(intCnt);
if( cvr.coverTypeDesc.toLowerCase() == "cover (front)"){
blnFrontFound = true;
intCnt = track.coverList.count + 1;
}
};
//if any cover is embedded, make it the front
if (blnFrontFound == false){
for(intCnt=0; intCnt < track.coverList.count; intCnt++){
if(track.coverList.getValue(intCnt).coverStorage = 0){
cvr = track.coverList.getValue(intCnt);
cvr.coverTypeDesc = "Cover (front)";
blnFrontFound = true;
intCnt = track.coverList.count + 1;
}
};
}
//if none found, make first image the front
if (blnFrontFound == false){
cvr = track.coverList.getValue(0);
cvr.coverTypeDesc = "Cover (front)";
}
cvrList = track.loadCoverListAsync();
// cvrList.whenLoaded(() => {
alert("h")
cvrList.modifyAsync(() => {
for(intCnt = cvrList.count-1; intCnt >= 0; intCnt--){
cvr = cvrList.getValue(intCnt);
alert(intCnt)
//delete all covers except for front cover
if( cvr.coverTypeDesc.toLowerCase() == "cover (front)"){
alert("embed")
//embed cover if not already
if (cvrList.getValue(intCnt).coverStorage != 0){
cvrList.getValue(intCnt).coverStorage = 0;
}
} else{
alert("delete")
cvrList.delete(intCnt);
}
}
});
// });
});
track.saveCoverListAsync;
track.commitAsync;
});
}
Hi,
I tried for a couple of hours to get the following code to work, however, I keep having problems. The last section is based off Ludek's suggestion and I end up with one of the following problems:
1) if I leave the whenloaded as suggested, the code never falls into the modifyAsync.
2) if I remove the whenloaded, it works just fine sometimes. Sometimes MM just hangs
3) If one of the covers is a link to a file and the file is deleted from the hard drive (not through the MM interface), MM hangs.
When MM hangs, I've noticed that if I attempt to close MM by clicking the "X" on the image in the taskbar, the track property window shows up. So it's like MM is waiting for a response to the property window, but I can't get focus to it.
Any help you can provide, I'd appreciate it.
[code]function removeAll() {
var blnFrontFound = false;
var intCnt = 0;
var cvr;
var cvrList;
trackList.forEach(function (track){
track.coverList.locked(function () {
//find first cover identified as the front (if any)
for(intCnt=0; intCnt < track.coverList.count; intCnt++){
cvr = track.coverList.getValue(intCnt);
if( cvr.coverTypeDesc.toLowerCase() == "cover (front)"){
blnFrontFound = true;
intCnt = track.coverList.count + 1;
}
};
//if any cover is embedded, make it the front
if (blnFrontFound == false){
for(intCnt=0; intCnt < track.coverList.count; intCnt++){
if(track.coverList.getValue(intCnt).coverStorage = 0){
cvr = track.coverList.getValue(intCnt);
cvr.coverTypeDesc = "Cover (front)";
blnFrontFound = true;
intCnt = track.coverList.count + 1;
}
};
}
//if none found, make first image the front
if (blnFrontFound == false){
cvr = track.coverList.getValue(0);
cvr.coverTypeDesc = "Cover (front)";
}
cvrList = track.loadCoverListAsync();
// cvrList.whenLoaded(() => {
alert("h")
cvrList.modifyAsync(() => {
for(intCnt = cvrList.count-1; intCnt >= 0; intCnt--){
cvr = cvrList.getValue(intCnt);
alert(intCnt)
//delete all covers except for front cover
if( cvr.coverTypeDesc.toLowerCase() == "cover (front)"){
alert("embed")
//embed cover if not already
if (cvrList.getValue(intCnt).coverStorage != 0){
cvrList.getValue(intCnt).coverStorage = 0;
}
} else{
alert("delete")
cvrList.delete(intCnt);
}
}
});
// });
});
track.saveCoverListAsync;
track.commitAsync;
});
}
[/code]