Porting scripts for MM 4.0

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

Moderators: Gurus, Addon Administrators

jiri
Posts: 5417
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Porting scripts for MM 4.0

Post by jiri »

I added a small Wiki section that describes changes that might be needed for some scripts, it's here: http://www.mediamonkey.com/wiki/index.p ... tallations

Feel free to post more examples/tips, in case you find some.

Thanks,
Jiri
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: Porting scripts for MM 4.0

Post by ZvezdanD »

Well, it is not enough to change only that. Here are some differences which I have discovered that could stop executing some scripts:
1. When track finish with reproduction with MM 3.x we had OnTrackProperties event , then OnTrackEnd, then OnPlaybackEnd; with 4.0 we have OnTrackEnd, then OnPlaybackEnd, then OnTrackProperties instead;

2. If you set SDBSongData.PlayCounter = 0, with MM3 SDBSongData.LastPlayed stays unchanged, but with MM4 it is set to 0 as well;

3. Setting SDB.MainTree.Node_XXX.Expanded = True/False not works anymore (this is obviously a bug and I hope it would be resolved as soon as possible since several of my scripts are using that);

4. Error because VarType(SDBSongData.FileLength) = 20 while it should be = 3 as before (one more bug);

5. some Web Browser controls are not displayed at all (Magic Nodes and RegExp scripts are affected); I am trying to find some solution, but I am afraid that this could be resolved only in the program itself.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
Peke
Posts: 17446
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: Porting scripts for MM 4.0

Post by Peke »

Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: Porting scripts for MM 4.0

Post by ZvezdanD »

Peke wrote:re 1. tracked and tested within http://www.ventismedia.com/mantis/view.php?id=7084
I am sorry, but your description in that report was not very clear to me. Beside of that, you are mentioning only change of PlayCount, but forgot to mention LastPlayed. And why you put that issue in Last.fm plugin Project when it could have some side effect with any script?
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: Porting scripts for MM 4.0

Post by ZvezdanD »

ZvezdanD wrote:5. some Web Browser controls are not displayed at all (Magic Nodes and RegExp scripts are affected); I am trying to find some solution, but I am afraid that this could be resolved only in the program itself.
I have found a reason for that and reported in Mantis: Second Web Browser control on form has serious problem with Common.Anchors property [4.x]
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
Eyal
Posts: 3116
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Re: Porting scripts for MM 4.0

Post by Eyal »

jiri wrote:I added a small Wiki section that describes changes that might be needed for some scripts, it's here:

Making scripts ready for per-user installations
Starting from MediaMonkey 4.0, scripts can be (and are suggested to be) installed per-user, and so they don't have to be installed in Program Files folder, but are installed in local Windows folders. The mechanism in MM is internally make as transparent as possible, so that scripts don't have to care much about their installed location. That said, some pre-4.0 scripts might need tweaking. For example, a popular script Lyricator has >1000 lines, but there's only one change needed in order to get it working under local installation, namely:

Dim sAppPath: sAppPath = sdb.ApplicationPath & "Scripts\Lyricator\"needs to be changed to

Dim sAppPath: sAppPath = sdb.ScriptsPath & "Lyricator\"
Hi,

I finally found why I had hard time debugging my new script under MM4!

- I'm running Windows XP, MM 3.2.4.
- I upgrade MM3 by installing MM4 in same folder. The folder already contained scripts in \Program Files\Mediamonkey\Scripts\Auto,
with my new script in it. So far so good. The script is working.
- I made some changes to my script, rebuilt the mmip and install it. The script now seems to run twice (?)

Reason: New mmip installation put the script in C:\Documents and Settings\Eyal\Application Data\MediaMonkey\Scripts\Auto, instead of overwriting the old one. So after restarting MM, 2 versions of the script are running simultaneously.

Here's the mmip:

Code: Select all

[Header]
ID=PlayedDateAndCounter
Title=Played Date & Counter
Description=Sets Played Date and Counter on playback startup
VersionMajor=1
VersionMinor=0
Type=Script

[Copy]
Src=PlayedDateAndCounter.vbs
Tgt={app}\Scripts\Auto\PlayedDateAndCounter.vbs

[Execute]
File={app}\Scripts\Auto\PlayedDateAndCounter.vbs
Function=OnStartup
I think {app}\ should install in application folder. {usr}\ or another variable name might be used to install into local folder.

Is that what you meant by "The mechanism in MM is internally make as transparent as possible, so that scripts don't have to care much about their installed location." ?

Thanks

Eyal :~)
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Re: Porting scripts for MM 4.0

Post by rovingcowboy »

Eyal wrote:
jiri wrote:I added a small Wiki section that describes changes that might be needed for some scripts, it's here:

Making scripts ready for per-user installations
Starting from MediaMonkey 4.0, scripts can be (and are suggested to be) installed per-user, and so they don't have to be installed in Program Files folder, but are installed in local Windows folders. The mechanism in MM is internally make as transparent as possible, so that scripts don't have to care much about their installed location. That said, some pre-4.0 scripts might need tweaking. For example, a popular script Lyricator has >1000 lines, but there's only one change needed in order to get it working under local installation, namely:

Dim sAppPath: sAppPath = sdb.ApplicationPath & "Scripts\Lyricator\"needs to be changed to

Dim sAppPath: sAppPath = sdb.ScriptsPath & "Lyricator\"
Hi,

I finally found why I had hard time debugging my new script under MM4!

- I'm running Windows XP, MM 3.2.4.
- I upgrade MM3 by installing MM4 in same folder. The folder already contained scripts in \Program Files\Mediamonkey\Scripts\Auto,
with my new script in it. So far so good. The scripts is working.
- I made some changes to my script, rebuilt the mmip and install it. The script now seems to run twice (?)

Reason: New mmip installation put the script in C:\Documents and Settings\Eyal\Application Data\MediaMonkey\Scripts\Auto, instead of overwriting the old one. So after restarting MM, 2 versions of the script are running simultaneously.

Here's the mmip:

Code: Select all

[Header]
ID=PlayedDateAndCounter
Title=Played Date & Counter
Description=Sets Played Date and Counter on playback startup
VersionMajor=1
VersionMinor=0
Type=Script

[Copy]
Src=PlayedDateAndCounter.vbs
Tgt={app}\Scripts\Auto\PlayedDateAndCounter.vbs

[Execute]
File={app}\Scripts\Auto\PlayedDateAndCounter.vbs
Function=OnStartup
I think {app}\ should install in application folder. {usr}\ or another variable name might be used to install local folder.

Is that what you meant by "The mechanism in MM is internally make as transparent as possible, so that scripts don't have to care much about their installed location." ?

Thanks

Eyal :~)

hey eyal for my skin mmip i just tried to get updated it put the skin name in the skins choice window twice you might have found the answer for me i'll look in that other place on mine for the extra skin.
roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy A51 5G Android ) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: Porting scripts for MM 4.0

Post by ZvezdanD »

Eyal wrote:I think {app}\ should install in application folder. {usr}\ or another variable name might be used to install into local folder.
I don't think so. If you introduce something like that, none existing installer package would be compatible with MM4. During installation of the new version of script/skin, the program itself should uninstall the old version of the same script/skin, not matter if it is previously installed in local or global folder and not matter of the current user choice of the installation folder.

I am going to report that in Mantis: Uninstall of old version of scripts/skins during installation of new version doesn't work always.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.8 / 4.0.1  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.5 / 2.3  Inherit Child Playlists 1.0.3  Add Currently Playing/Selected Track(s) to Playlist 1.2
Ludek
Posts: 4945
Joined: Fri Mar 09, 2007 9:00 am

Re: Porting scripts for MM 4.0

Post by Ludek »

Eyal wrote: - I'm running Windows XP, MM 3.2.4.
- I upgrade MM3 by installing MM4 in same folder. The folder already contained scripts in \Program Files\Mediamonkey\Scripts\Auto,
with my new script in it. So far so good. The script is working.
- I made some changes to my script, rebuilt the mmip and install it. The script now seems to run twice (?)
Thanks, fixed as http://www.ventismedia.com/mantis/view.php?id=7273
Eyal
Posts: 3116
Joined: Sun Jun 26, 2005 9:27 am
Location: Québec

Re: Porting scripts for MM 4.0

Post by Eyal »

Thank you.
Skins for MediaMonkey: Cafe, Carbon, Helium, Spotify, Zekton. [ Wiki Zone ].
Psyker7
Posts: 255
Joined: Sat Mar 03, 2007 8:00 am

Re: Porting scripts for MM 4.0

Post by Psyker7 »

In terms of creating files to be used by the script, is it better to use Script.ScriptPath or %appdata%\mediamonkey?

I just went and re-wrote my script to use %appdata% to now discover MM4 can install scripts to %appdata% now.

Given I would prefer it to be compatible with MM3 & 4, I'm thinking using %appdata% is the best option for now...
Post Reply