Newbie Questions

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Newbie Questions

Re: Newbie Questions

by drakinite » Tue Nov 09, 2021 9:00 pm

Not sure myself - I'd say put it in the beta testing/bugs/feature requests channel, to see if the idea gets any traction.

Re: Newbie Questions

by MPG » Tue Nov 09, 2021 4:41 pm

Thanks for the response. Any chance we can request it to be added, or have the toolbar enhanced to have functionality similar to mm4?

Re: Newbie Questions

by drakinite » Tue Nov 09, 2021 4:36 pm

Not by default, no. The three toolbutton categories in the main window bar are lefttoolbuttons, viewtoolbuttons, and righttoolbuttons. You could add your own category, but it would require adding a new container to the that main toolbar and adding CSS styling to make it fit.

Re: Newbie Questions

by MPG » Tue Nov 09, 2021 9:30 am

Submitted the file yesterday. Thanks for the help Pete!

On the call, window.uitools.addToolButton, is it possible to use centertoolbuttons instead of right righttoolbuttons? I'd like my addons grouped together in the center of the toolbar and in a specific order.

Re: Newbie Questions

by Peke » Mon Nov 08, 2021 6:59 am

MPG wrote: Sun Nov 07, 2021 11:30 pm Hi drakinite,
I attempted to upload my solution and when I added the mmip file I am receiving the following error:
Unable to read file information from the "Install.ini"

I don't have an ini file. Should I?
The best woudl be to open support Ticket and send us MMIP. Someone will look at it ASAP.

Re: Newbie Questions

by drakinite » Mon Nov 08, 2021 5:47 am

It needs to either have a valid install.ini (MM4) or a valid info.json (MM5). Did you make sure the folder structure is correct?

Re: Newbie Questions

by MPG » Sun Nov 07, 2021 11:30 pm

Hi drakinite,
I attempted to upload my solution and when I added the mmip file I am receiving the following error:
Unable to read file information from the "Install.ini"

I don't have an ini file. Should I?

Re: Newbie Questions

by drakinite » Sat Nov 06, 2021 5:34 pm

Great! Wanna add it to the Addons listing? I haven't yet written on the Wiki about how to submit addons, but I wrote instructions in this forum reply: viewtopic.php?p=482637#p482637

If you don't yet know how to create an MMIP (addon installer), it's simple: https://www.mediamonkey.com/wiki/Gettin ... ackages.29

Re: Newbie Questions

by MPG » Sat Nov 06, 2021 2:52 pm

Yep that worked. Strange, I had it reversed for quite some time and it never worked, so I switched them. Anyway...I'm off the races, on to the next one. If anyone wants the solution, I can make it available. Just send me a PM.

The solution allows you to replace text in title, Artist, Album, Album Artist, or All of them.

I use it to remove "&" with the word "And" as it causes difficulties in doing searches.

Re: Newbie Questions

by drakinite » Sat Nov 06, 2021 2:39 pm

MPG wrote: Sat Nov 06, 2021 12:08 pm

Code: Select all

window._menuItems.editTags.action.submenu.push({
        action: actions.ReplaceString,
        order: 30,
        grouporder: 20
});

actions.ReplaceString = {
	title: _('Replace String') + '...',
	hotkeyAble: true,
	icon:'ReplaceString',
	disabled: uitools.notMediaListSelected,
    visible: window.uitools.getCanEdit,
    execute: async function () {
		// get list of selected songs
		var list = uitools.getSelectedTracklist();
        var dlg = uitools.openDialog('dlgReplaceString', {
            show: true,
            modal: true,
            title: _('Replace String'),
            tracks: list
        });
	}
}
I think I know your issue. If your code is written in that order, then it won't work. You need to define actions.ReplaceString before you add it to the editTags list.
As it is now, your code is doing the following:

Code: Select all

window._menuItems.editTags.action.submenu.push({
        action: [b]undefined[/b],
        order: 30,
        grouporder: 20
});
That is because at the time you are pushing that to the list, actions.ReplaceString is undefined.

Also, I don't believe you can directly specify an icon on the submenu list, because the icons are controlled by the action. But I see that you already specified an icon inside actions.ReplaceString, so you should be good once it works.

Re: Newbie Questions

by MPG » Sat Nov 06, 2021 12:08 pm

Hey drakinite,
I'm making serious headway....the script loads on the toolbar and the icon is now displayed....even has scroll over help text. :)

Unfortunately, the script is not being added to the EditTags submenu. :( The code I have in the actions_add.js file is

Code: Select all

window._menuItems.editTags.action.submenu.push({
        action: actions.ReplaceString,
        order: 30,
        grouporder: 20
});

actions.ReplaceString = {
	title: _('Replace String') + '...',
	hotkeyAble: true,
	icon:'ReplaceString',
	disabled: uitools.notMediaListSelected,
    visible: window.uitools.getCanEdit,
    execute: async function () {
		// get list of selected songs
		var list = uitools.getSelectedTracklist();
        var dlg = uitools.openDialog('dlgReplaceString', {
            show: true,
            modal: true,
            title: _('Replace String'),
            tracks: list
        });
	}
}
I expected the "push" code to add the ReplaceString call to the submenu.

Also, can I add icon to the "push" code? Something along the lines of:
window._menuItems.editTags.action.submenu.push({
action: actions.ReplaceString,
order: 30,
grouporder: 20
icon: 'ReplaceString'
});
I've tried the call, it doesn't fail, but it doesn't add the icon or the call to the submenu.

Re: Newbie Questions

by drakinite » Fri Nov 05, 2021 6:03 pm

I can't tell; I haven't used embedded images in SVGs before. Try using an existing icon, like "options" or "music" to see if your toolbutton shows up. Also, did you place it in skin/icon/<name>.svg?

Re: Newbie Questions

by MPG » Fri Nov 05, 2021 2:41 pm

Thanks for your help....I'm getting closer and closer...
Questions 1, 2 & 4 are resolved.
I'm still not getting my add-on to add itself to the toolbar and the sub-menu. Could it be due to my image file as it isn't loading either.

the original svg file is:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="480" height="335" viewBox="0 0 480 335" xml:space="preserve">
<desc>Created with Fabric.js 3.6.3</desc>
<defs>
</defs>
<g transform="matrix(0.97 0 0 0.97 240.06 167.94)"  >
<image style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;"  xlink:href="data:image/png;base64,... (the image code)
</g>
</svg>
My updated file:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: svgeditoronline.com  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" style="enable-background:new 0 0 1000 1000;" xml:space="preserve">
<desc>Created with Fabric.js 3.6.3</desc>
<defs>
</defs>
<g transform="matrix(0.97 0 0 0.97 240.06 167.94)"  >
	<image style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;"  xlink:href="data:image/png;base64,...(the image code)
	</g>
</svg>
See anything blatantly wrong?

Re: Newbie Questions

by drakinite » Thu Nov 04, 2021 6:23 pm

Great to have you migrating your scripts!

1) The answer to your question about _add files and init.js can be found here: https://www.mediamonkey.com/wiki/Gettin ... dons)#Code
There's nothing intrinsically special about local.js; it's just an extra script you can call with localRequirejs (more info here: https://www.mediamonkey.com/wiki/Import ... #requirejs)

2) Could you show me more of your code? Does it await the tracklist's whenLoaded() ?

3) If you've created actions.ReplaceString and it already has code to open the dlgReplaceString dialog inside its execute function, you could do the following instead of your provided toolbutton code:

Code: Select all

window.uitools.addToolButton('righttoolbuttons', 'javascript', actions.ReplaceString.execute);
Just make sure that you define actions.ReplaceString inside actions_add.js. If it's created in a different file, it might not load properly.

4) https://www.mediamonkey.com/wiki/Gettin ... oring_Data
If your dialog has an OK button, then you should listen to its "click" event and do all your business code there. You can then retrieve the values of your controls (i.e. checkboxes, dropdowns, text inputs, etc.) and store them with app.setValue. For an example, check out the Split Multi-Value Fields addon.

5) You can use any vector graphics editor, such as Adobe Illustrator (paid) or Inkscape (free). Looks like there's also a free web-based one: http://svgeditoronline.com/editor/
Sometimes the SVG code that's output from those programs doesn't play nice with MediaMonkey, so you might have to edit the code after the fact. If an icon doesn't display properly, try changing the <svg> at the top with this:

Code: Select all

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 viewBox="0 0 1000 1000" style="enable-background:new 0 0 1000 1000;" xml:space="preserve">
The viewBox attribute might lead to the icon scaling wrong, so you might need to change the numbers around a bit.
It's definitely not an exact science, but with some trial and error, you can get it to work!

Newbie Questions

by MPG » Tue Nov 02, 2021 9:36 pm

VB programmer here, and I'm trying to migrate some custom functionality from MM4 to MM5.
For the most part I am having some success as I can some solutions to load but as you might expect, this javascript is a new beast. As you might expect, I have some newbie questions:

1) What are the actions_add.js, init.js and local.js files? How are they interrelated?

2) I have some code that is able to obtain the songs that are selected when the solution is added to the Edit Tags Submenu, but the same code doesn't work, when I add the solution to the top toolbar:
the actions_add file does the following:
var list = uitools.getSelectedTracklist();
- I then pass "list" as part of the openDialog call.
- "list" isn't populated when opened from the toolbar.

3) I want my solution to be added to the Edit Tags submenu and the toolbar. Seems I can do one or the either, but not both.
To add my solution to the toolbar I have the following in the local.js:
(function () {
window.uitools.addToolButton('righttoolbuttons', 'javascript' /* icon */ , function () {
var dlg = uitools.openDialog('dlgReplaceString', {
show: true,
notShared: true,
title: 'Replace String',
});
});
})();

To add my solution to the submenu I have the following in the actions_add.js:
window._menuItems.editTags.action.submenu.push({
action: actions.ReplaceString,
order: 30,
grouporder: 20
});

4) How do I save and retrieve the values entered in a dialog screen?

5) How does one go about creating a svg file?

Top