Play albums randomly

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

jaxjon
Posts: 102
Joined: Tue May 27, 2003 8:47 am
Location: Florida USA

Play albums randomly

Post by jaxjon »

Does anyone know if a script can be formed to play full albums randomly through MM, kind of shuffle play with albums instead of tracks? If so please point me in the right direction.

Thank you

Jon
Lowlander
Posts: 56643
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Post by Lowlander »

No I don't think such a thing exists.

It would be nice if such advanced queries could be done with the advanced search in MM Gold.
jaxjon
Posts: 102
Joined: Tue May 27, 2003 8:47 am
Location: Florida USA

Post by jaxjon »

Here is a script that does nothing more than can be done now in MM, but I would like to take this as a start and try to add to it. I would like to know how to

1. Sort the list by album .
2. Randomize the albums. (Rnd?)
3. Play each album in its entirety then move to next.

I have tried using SDB.AllVisibleSongList.Albums but I get an error when doing so
I also get memory error if too many files are added to playlist, don't know why?

I know I can play albums in an order in MM now but I cannot play them randomly.

Thank you for any input.

Code: Select all

Sub PlayInMM
Dim list, itm, i,

' Set List
Set list = SDB.SelectedSongList
If list.count=0 Then
Set list = SDB.AllVisibleSonglist
If list.count=0 Then
res = SDB.MessageBox( "Select Tracks to be exported, please.", mtError, Array(mbOk))
Exit Sub
End If
End If

Set plr=SDB.Player
plr.PlaylistClear

Dim Progress
Set Progress = SDB.Progress
Progress.Text = "Working..."


'Export to MM all songs
Progress.MaxValue = list.count

for i=0 to list.count-1
Set itm = list.Item(i)

'add tracks to playlist
plr.PlaylistAddTrack(itm)


Progress.Value = i+1
if Progress.Terminate then
Exit For
end if
next

'play tracks
plr.Play

End Sub

Code: Select all

[PlayInMM] 
FileName=PlayInMM.vbs 
ProcName=PlayInMM 
Order=1 
DisplayName=Play In MM (2) 
Description=Plays In MM Player 
Language=VBScript 
ScriptType=0 
Lowlander
Posts: 56643
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Post by Lowlander »

Well somehow you need to group the tracks on albums together. Arrays might be a way to go.
jaxjon
Posts: 102
Joined: Tue May 27, 2003 8:47 am
Location: Florida USA

Post by jaxjon »

Alright, this works, but I am still looking for a good way to loop back to the top when the last song has played. Any suggestions?

The reason for recognizing only all visible songs is so if you click around in MM main track list then it still picks from the big list.

Works best if main track listing is in track order 1-n, that way it will alway play album in correct order.

Hope you like.



Code: Select all

Sub PlayAlbum
Dim list, itm, i, a, b
' Set List
Set list = SDB.AllVisibleSonglist
If list.count=0 Then
res = SDB.MessageBox( "Select Tracks to be exported, please.", mtError, Array(mbOk))
Exit Sub
End If

Set plr=SDB.Player
plr.PlaylistClear

Dim Progress
Set Progress = SDB.Progress
Progress.Text = "Working..."

'Export to MM all songs
Progress.MaxValue = list.count

Randomize
i=0
i = Int(((list.count-1) * Rnd) + 1)
Set itm = list.Item(i)

a = itm.AlbumName

For b=0 to list.count-1
Set itm=list.item(b)

If itm.AlbumName=a Then

plr.PlaylistAddTrack(itm)

Progress.Value=b+1

If Progress.Terminate Then
Exit For

End If
End If
Next

plr.Play

End Sub

Code: Select all

[PlayAlbum] 
FileName=PlayAlbum.vbs 
ProcName=PlayAlbum 
Order=1 
DisplayName=Play Full Album 
Description=Plays Full Album 
Language=VBScript 
ScriptType=0 
jaxjon
Posts: 102
Joined: Tue May 27, 2003 8:47 am
Location: Florida USA

Post by jaxjon »

The script now will loop to a new album when finished, in a non simplistic way. I had to create another script and give it a ScriptType=2, this script also has the original script included so it can call it. You need both scripts and references to both in scripts.ini. I also added another file (song) called "End". This is a file of short length and little or no sound, I used Utopia Critical Stop.wav and converted to wma and changed title to "End". You can see reference to it in PlayAlbum script(put this song in main track list, so it is there with all other visible songs). This is so when the album is finished there is a buffer between previous album and next album. I would like to use isPlaying= False to find end of album but with ScriptType=2 scripts the script is only run at start of song and at that point isPlaying is always True. It would be great if there was a way the script could be run at end of song also, perhaps call it ScriptType=3. I think it is impossible to loop a single script to constantly check for change without hanging. If there is already a way to do it, please let me know.

Is there is a way to check the current playlist (in nowplaying window) to see if the current song has title of "End" so the checker script will call PlayAlbum only if the last song in the playlist is "End", tried PlaylistItems to generate object but did not work, I must be doing it wrong.

Thank you

Code: Select all

[PlayAlbum] 
FileName=PlayAlbum.vbs 
ProcName=PlayAlbum 
Order=1 
DisplayName=Play Full Album 
Description=Plays Full Album 
Language=VBScript 
ScriptType=0 

[Checker] 
FileName=Checker.vbs 
ProcName=Checker 
Order=1 
DisplayName=Checker 
Description=Checker 
Language=VBScript 
ScriptType=2 

Code: Select all

Sub PlayAlbum
Dim list, itm, i, a, b, c
' Set List
Set list = SDB.AllVisibleSonglist
If list.count=0 Then
res = SDB.MessageBox( "Select Tracks to be exported, please.", mtInformation, Array(mbOk))
Exit Sub
End If
Set plr=SDB.Player


plr.PlaylistClear

Dim Progress
Set Progress = SDB.Progress
Progress.Text = "Working..."

'Export to MM all songs
Progress.MaxValue = list.count

Randomize
i=0
i = Int(((list.count-1) * Rnd) + 1)
Set itm = list.Item(i)

a = itm.AlbumName

For b=0 to list.count-1
Set itm=list.item(b)

If itm.AlbumName = a Then

plr.PlaylistAddTrack(itm)

Progress.Value=b+1

If Progress.Terminate Then
Exit For

End If
End If

Next
For c=0 to list.count-1
Set itm=list.item(c)
If itm.Title="End" Then
plr.PlaylistAddTrack(itm)
End If
Next
plr.Play


End Sub 

Code: Select all

Sub Checker
Set plr=SDB.Player
If (plr.PlaylistCount) = (plr.CurrentSongIndex +1) Then
Call PlayAlbum
End If
End Sub


Sub PlayAlbum
Dim list, itm, i, a, b, c
' Set List
Set list = SDB.AllVisibleSonglist
If list.count=0 Then
res = SDB.MessageBox( "Select Tracks to be exported, please.", mtInformation, Array(mbOk))
Exit Sub
End If
Set plr=SDB.Player


plr.PlaylistClear

Dim Progress
Set Progress = SDB.Progress
Progress.Text = "Working..."

'Export to MM all songs
Progress.MaxValue = list.count

Randomize
i=0
i = Int(((list.count-1) * Rnd) + 1)
Set itm = list.Item(i)

a = itm.AlbumName

For b=0 to list.count-1
Set itm=list.item(b)

If itm.AlbumName = a Then

plr.PlaylistAddTrack(itm)

Progress.Value=b+1

If Progress.Terminate Then
Exit For

End If
End If

Next
For c=0 to list.count-1
Set itm=list.item(c)
If itm.Title="End" Then
plr.PlaylistAddTrack(itm)
End If
Next
plr.Play


End Sub 
Last edited by jaxjon on Sun May 30, 2004 5:53 pm, edited 1 time in total.
jaxjon
Posts: 102
Joined: Tue May 27, 2003 8:47 am
Location: Florida USA

Post by jaxjon »

You could also just have Checker.vbs and add this to Scripts.ini

Code: Select all

[PlayAlbum] 
FileName=Checker.vbs 
ProcName=PlayAlbum 
Order=1 
DisplayName=Play Full Album 
Description=Plays Full Album 
Language=VBScript 
ScriptType=0 

[Checker] 
FileName=Checker.vbs 
ProcName=Checker 
Order=1 
DisplayName=Checker 
Description=Checker 
Language=VBScript 
ScriptType=2 
Post Reply