How to start MM5 with a playlist in shuffle mode? [#17174]

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

Moderators: jiri, drakinite, Addon Administrators

bege
Posts: 18
Joined: Fri Feb 18, 2011 10:45 am
Location: Germany

How to start MM5 with a playlist in shuffle mode? [#17174]

Post by bege »

With MM4 I used this script to start the program with a playlist in shuffle mode. The list started with a random piece and continued shuffling.

Code: Select all

'==========================================================================
'
' NAME: Mediamonkey Scheduled Playlist Start v1.1
'
' AUTHOR: Peke
' DATE  : 16.10.2005
'
' INSTALL: 1. Read info above line with 'Playlist ='
'          2. Just start Script in Scheduled time and MediaMonkey Will play
'             desired playlist.
'
' COMMENT: This is third party Windows Host Script that takes advantage of
'          MediaMonkey to play desired Playlist at desired time.
'
' NOTE: Mediamonkey needs to be started before script executes
'
'==========================================================================
Dim SDB, Songs
Set SDB = CreateObject("SongsDB.SDBApplication")
SDB.ShutdownAfterDisconnect = False

Sdb.player.playlistclear
Dim i
For i = 0 To (WSH.Arguments.Count-1)
  sdb.player.playlistaddtracks(SDB.PlaylistByTitle(WSH.Arguments.Item(i)).tracks)
Next
If SDB.Player.isPlaying or SDB.Player.isPaused then
  SDB.Player.Stop
End If
Randomize
SDB.Player.CurrentSongIndex = Int((SDB.Player.PlaylistCount+1) * Rnd)
SDB.player.Play
I started MM4 with this command:

Code: Select all

C:\Program Files (x86)\MediaMonkey\Scripts\Play Playlists Randomized.vbs PlaylistName
I copied this script to the scripts folder in MM5 and changed the command to

Code: Select all

C:\Program Files (x86)\MediaMonkey 5\Scripts\Play Playlists Randomized.vbs PlaylistName
but it still starts MM4 (I find

Code: Select all

SongsDB.SDBApplication
still linked to MM4 in the registry).

How can I accomplish this feature with MM5? (I am no developer, I simply used the script.)
Lowlander
Posts: 51493
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: How to start MM5 with a playlist in shuffle mode?

Post by Lowlander »

Most MediaMonkey 4 Scripts/Addons are not compatible with MediaMonkey 4. Where MMW4 Scripts are often VBScript based, in MediaMonkey 5 JS is normally used.

For more see: https://www.mediamonkey.com/forum/viewt ... 27&t=86756
drakinite
Posts: 645
Joined: Tue May 12, 2020 10:06 am
Contact:

Re: How to start MM5 with a playlist in shuffle mode?

Post by drakinite »

Most of the COM API is still supported, but you'll need to instantiate it with SongsDB5.SDBApplication instead of SongsDB.SDBApplication.
https://www.mediamonkey.com/wiki/Contro ... plications

However, I just now attempted to run that script and it led to a crash, so it might not be quite recommended to use yet. :wink:

In the meantime, there is a dedicated shuffle button for playlists within the MM5 application. I'll investigate the crash.
EDIT: It's a known issue; tracked as https://www.ventismedia.com/mantis/view.php?id=17174
Image
Student electrical-computer engineer, web programmer, part-time MediaMonkey developer, full-time MediaMonkey enthusiast
drakinite
Posts: 645
Joined: Tue May 12, 2020 10:06 am
Contact:

Re: How to start MM5 with a playlist in shuffle mode?

Post by drakinite »

Btw, I know you said you're not a developer; but if you *are* interested, you can take a look at how to create addons here: https://www.mediamonkey.com/wiki/Gettin ... d_(Addons)

It's simpler than you might expect. :grin:
Image
Student electrical-computer engineer, web programmer, part-time MediaMonkey developer, full-time MediaMonkey enthusiast
bege
Posts: 18
Joined: Fri Feb 18, 2011 10:45 am
Location: Germany

Re: How to start MM5 with a playlist in shuffle mode?

Post by bege »

drakinite wrote: Tue Apr 27, 2021 7:44 pm Most of the COM API is still supported, but you'll need to instantiate it with SongsDB5.SDBApplication instead of SongsDB.SDBApplication.
https://www.mediamonkey.com/wiki/Contro ... plications

However, I just now attempted to run that script and it led to a crash, so it might not be quite recommended to use yet. :wink:

In the meantime, there is a dedicated shuffle button for playlists within the MM5 application. I'll investigate the crash.
EDIT: It's a known issue; tracked as https://www.ventismedia.com/mantis/view.php?id=17174
After a long time I tried it again because the issue seems to be fixed.

Because the wiki https://www.mediamonkey.com/wiki/Contro ... plications says that
"The SDBApplication class is largely unchanged from MediaMonkey 4, but the biggest difference is that it is named SongsDB5.SDBApplication instead of SongsDB.SDBApplication"
I simply changed that part of the script and executed it again.

Code: Select all

C:\Program Files (x86)\MediaMonkey 5\Scripts\Play Playlists Randomized.vbs PlaylistName

Code: Select all

Dim SDB, Songs
Set SDB = CreateObject("SongsDB5.SDBApplication")
SDB.ShutdownAfterDisconnect = False

Sdb.player.playlistclear
Dim i
For i = 0 To (WSH.Arguments.Count-1)
  sdb.player.playlistaddtracks(SDB.PlaylistByTitle(WSH.Arguments.Item(i)).tracks)
Next
If SDB.Player.isPlaying or SDB.Player.isPaused then
  SDB.Player.Stop
End If
Randomize
SDB.Player.CurrentSongIndex = Int((SDB.Player.PlaylistCount+1) * Rnd)
SDB.player.Play
No crash and three MM5 processes are being started: :D
"C:\PROGRA~2\MediaMonkey 5\MediaMonkey.exe" -Embedding
"C:\PROGRA~2\MediaMonkey 5\MediaMonkeyEngine.exe" --type=utility --utility-sub-type=network.mojom.NetworkService --field-trial-handle=3528,4776923566102479129,9490495931099042589,131072 --disable-features=IsolateOrigins,site-per-process --lang=en-US --service-sandbox-type=none --no-sandbox --locales-dir-path="C:\PROGRA~2\MediaMonkey 5\chromium\90\locales" --log-file="C:\PROGRA~2\MediaMonkey 5\debug.log" --log-severity=disable --lang=en-US --log-file="C:\PROGRA~2\MediaMonkey 5\debug.log" --mojo-platform-channel-handle=3536 /prefetch:8
"C:\PROGRA~2\MediaMonkey 5\MediaMonkeyEngine.exe" --type=renderer --no-sandbox --autoplay-policy=no-user-gesture-required --js-flags="\"--expose-gc\"" --log-file="C:\PROGRA~2\MediaMonkey 5\debug.log" --remote-debugging-port=9222 --field-trial-handle=3528,4776923566102479129,9490495931099042589,131072 --disable-features=IsolateOrigins,site-per-process --lang=en-US --locales-dir-path="C:\PROGRA~2\MediaMonkey 5\chromium\90\locales" --log-file="C:\PROGRA~2\MediaMonkey 5\debug.log" --log-severity=disable --uncaught-exception-stack-size=10 --device-scale-factor=1.25 --num-raster-threads=2 --enable-main-frame-before-activation --renderer-client-id=4 --mojo-platform-channel-handle=3732 /prefetch:1
but no UI comes to the foreground. :(

When I start MM5 normally the main process starts without the

Code: Select all

-Embedding
argument. Does that prevent the UI from starting? How can I fix that?
Peke
Posts: 14912
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Re: How to start MM5 with a playlist in shuffle mode? [#17174]

Post by Peke »

Hi,
WOW! My 16 years script for playlist is still working :)

I guess that this can be also improved and I created https://www.ventismedia.com/mantis/view.php?id=18453 so that MM5 existing internal feature (Right click on Playlist -> Play Shuffled) can be added/executed thru command line.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum
bege
Posts: 18
Joined: Fri Feb 18, 2011 10:45 am
Location: Germany

Re: How to start MM5 with a playlist in shuffle mode? [#17174]

Post by bege »

Peke wrote: Fri Oct 22, 2021 3:57 am Hi,
WOW! My 16 years script for playlist is still working :)

I guess that this can be also improved and I created https://www.ventismedia.com/mantis/view.php?id=18453 so that MM5 existing internal feature (Right click on Playlist -> Play Shuffled) can be added/executed thru command line.
Hi Peke,
nice to see you here again. Yes, I still used it with MM4.
Do I understand you correct that you cannot fix that script for MM5 but think of adding that (enhanced) feature as a command line option to MM5?
Best regards
Peke
Posts: 14912
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Re: How to start MM5 with a playlist in shuffle mode? [#17174]

Post by Peke »

Hi,
It should be possible to make it work with MM5, but in all case the best approach would be to Rewrite it and make new one for MM5.

Maybe @Drakinite can help with rewrite.

New command line is added to further enhance MM5 and its support for external execution of both Scripts and internal functions in future versions of MM, because it is obvious that after 16 years there is still need for such features.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum
bege
Posts: 18
Joined: Fri Feb 18, 2011 10:45 am
Location: Germany

Re: How to start MM5 with a playlist in shuffle mode? [#17174]

Post by bege »

Peke wrote: Fri Oct 22, 2021 5:57 am Hi,
It should be possible to make it work with MM5, but in all case the best approach would be to Rewrite it and make new one for MM5.

Maybe @Drakinite can help with rewrite.

New command line is added to further enhance MM5 and its support for external execution of both Scripts and internal functions in future versions of MM, because it is obvious that after 16 years there is still need for such features.
👍
Post Reply