No "OnStartup" event in MM4 [#8482]

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

Moderators: Gurus, Addon Administrators

markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

No "OnStartup" event in MM4 [#8482]

Post by markstuartwalker »

This has been removed in MM4. Why?

http://www.mediamonkey.com/wiki/index.p ... ts_members

I would like Clear Now Playing to work but it seems to need this even to operate. (http://www.mediamonkey.com/forum/viewto ... 35#p313935)
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
jiri
Posts: 5419
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Re: 1441 No "OnStartup" event in MM4

Post by jiri »

It was actually an error in documentation, this event hasn't ever existed.

If you need to do anything on startup, you probably could do so when the script is first called?

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

Re: 1441 No "OnStartup" event in MM4

Post by ZvezdanD »

I don't understand what you are talking about. How is that that this event hasn't ever existed? All my auto-scripts has OnStartup event handler which is executed on every start-up of the program - MM2, MM3 as well as MM4 (tried with many versions, even the latest build 1442). Actually, none of my auto-scripts could be used without that event since I am setting the menu items for the script's options and other initialization code during the start-up.
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: 4964
Joined: Fri Mar 09, 2007 9:00 am

Re: 1441 No "OnStartup" event in MM4

Post by Ludek »

Zvezdan, this works correctly for me with the latest build:

Code: Select all

Option Explicit

Dim UI  : Set UI = SDB.UI

Sub OnStartUp()
    Dim mnuTest

    Set mnuTest = SDB.UI.AddMenuItem(SDB.UI.Menu_Edit, 0, 0)
    mnuTest.Caption = SDB.Tools.RemapASCII("BLA BLA")
    mnuTest.OnClickFunc = "Test1"
    mnuTest.UseScript = Script.ScriptPath
End Sub
The "BLA BLA" is correctly added to Edit menu.

So what is wrong here?
markstuartwalker
Posts: 931
Joined: Fri Jul 10, 2009 8:10 am

Re: 1441 No "OnStartup" event in MM4

Post by markstuartwalker »

OK, so everyone except Jiri seems to think that the Sub OnStartup() gets called in both MM3 and MM4

... and I've been back to my original test to find that it works fine. Doh!

So, are we just looking at a documentation problem?
Windows 7,8 / Ubuntu 13.10 / Mavericks 10.9 / iOS 7.1 / iTunes 11.1
iTunes plugin (d_itunes & itunes4) http://www.mediamonkey.com/forum/viewto ... =2&t=45713
Running MM under Mac OS X with Wine http://www.mediamonkey.com/forum/viewto ... =4&t=58507
ZvezdanD
Posts: 3257
Joined: Thu Jun 08, 2006 7:40 pm

Re: 1441 No "OnStartup" event in MM4

Post by ZvezdanD »

Ludek wrote:So what is wrong here?
Please read my previous post again. That are my words exactly - there is nothing wrong there, OnStartup works fine in MM4 as it was before. However, wrong is jiri who removed a description of that event from wiki claiming that it has never existed.
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: 17493
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: 1441 No "OnStartup" event in MM4

Post by Peke »

It was error in documentation That needs to be fixed as like you pointed Zvezdan it works as it was always worked eg. executed on Auto-Script startup. it is not regular Event you can hook on like with OnPlay.

I explained this in http://www.ventismedia.com/mantis/view.php?id=8482

NOTE: OnShutdown event also do not belong there. Documentation should be updated/fixed.
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: 1441 No "OnStartup" event in MM4

Post by ZvezdanD »

Peke wrote: it is not regular Event you can hook on like with OnPlay.

I explained this in http://www.ventismedia.com/mantis/view.php?id=8482

NOTE: OnShutdown event also do not belong there. Documentation should be updated/fixed.
Well, strictly speaking, you are right that OnStartup is not regular event since it cannot be registered with the Application object, but it should be mentioned there anyway. How do you expect that scripters learn for that event handler if you don't mention it in wiki?

OnShutdown event should belong there for sure since it could be registered as e.g. OnPlay, for example:
Script.RegisterEvent SDB, "OnShutdown", "ClearIniSection"
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
jiri
Posts: 5419
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Re: No "OnStartup" event in MM4 [#8482]

Post by jiri »

So, just to summarize:

- There really haven't ever existed OnStartup COM event.
- OnStartup procedure of a script (if exists) is automatically called on startup. Since it the old way of calling script procedures, it would make sense to deprecate it in the next version of MM and rather implement the COM event.

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

Re: No "OnStartup" event in MM4 [#8482]

Post by ZvezdanD »

jiri wrote:OnStartup procedure of a script (if exists) is automatically called on startup. Since it the old way of calling script procedures, it would make sense to deprecate it in the next version of MM and rather implement the COM event.
Will you keep compatibility with the existing scripts after that implementation?
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
jiri
Posts: 5419
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Re: No "OnStartup" event in MM4 [#8482]

Post by jiri »

Definitely, at least for a limited time (of few year?) to allow update of scripts.

Jiri
Post Reply