
But I wonder how to use it. Do I have to write something in the customfield to tie songs toghether?
Yes. Tracks within one group are played in order by track number.Dreadlau wrote:Just one last question: How does the script knows in wich order to play the tracks? Does it relate on the Track Numbers?
Code: Select all
'==========================================================================
'
' MediaMonkey Script
'
' NAME: TiedSongsGroups v1.0
' DESCRIPTION:
' Lets you make groups of songs, so when one song of the group is played,
' the next songs in the group are also played (in order).
'
' AUTHOR: Steegy aka RC (Ruben Castelein)
' DATE : 28.02.2006
' UPDATE: 28.02.2006
'
' 16/06/2008: Modified by Rycher to put all the tracks from the same group (not just those after).
'
' INSTALL:
' - Copy script to MediaMonkey's "Scripts" folder
' - Add an script entry to file Scripts.ini (example shown below)
'
' [TiedSongsGroups]
' FileName=TiedSongsGroups.vbs
' ProcName=OnSongStartsPlaying
' Order=1
' DisplayName=TiedSongsGroups
' Description=TiedSongsGroups
' Language=VBScript
' ScriptType=2
'
' USE:
' For songs you want in one group, change the Custom3 field for these songs to
' the same value, beginning with TG (this indicates a "tied group").
' E.g. for an album "Pink Floyd - Dark Side of the Moon" you can change the Custom3 field
' for all tracks to "TG Pink Floyd - Dark Side of the Moon". (without quotation marks).
' Bear in mind that shorter values for the Custom3 field are faster (so better "TG PF-DSOTM")
' Order of tracks in a tied group is indicated using the standard Track Number field.
'
'==========================================================================
'>> ForumURL: http://www.mediamonkey.com/forum/viewtopic.php?t=8464
'>> ScriptName: TiedSongsGroups
'>> VersionNumber: 1.0
'>> Author: Steegy aka RC (Ruben Castelein)
'>>>>EndOfProperties
'##############################################################################################
Sub OnSongStartsPlaying
If Left(SDB.Player.CurrentSong.Custom3, 2) = "LT" Then
If Not SDB.IniFile.StringValue("Player", "saved_hasBeenSaved") = "True" Then
SDB.IniFile.StringValue("Player", "saved_hasBeenSaved") = "True"
SavePlayerStates
End If
If SDB.Player.CurrentSongIndex = SDB.Player.PlaylistCount - 1 Then
'Last song in playlist
PlayerStatesAsContinuous
AddOtherTiedSongs
Else
If (SDB.Player.CurrentSongIndex = 0) Then
' First song in playlist
PlayerStatesAsContinuous
Else
If (SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex - 1).Custom3 <> SDB.Player.CurrentSong.Custom3 OR SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex - 1).TrackOrder <> SDB.Player.CurrentSong.TrackOrder-1) AND (SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1).Custom3 <> SDB.Player.CurrentSong.Custom3 OR SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1).TrackOrder <> SDB.Player.CurrentSong.TrackOrder+1) Then
'Non-tied song before and after
AddOtherTiedSongs
Else
'Tied song
PlayerStatesAsContinuous
End If
End If
End If
Else
If SDB.IniFile.StringValue("Player", "saved_hasBeenSaved") = "True" Then
SDB.IniFile.StringValue("Player", "saved_hasBeenSaved") = "False"
RestoreSavedPlayerStates
End If
End If
End Sub
Sub AddOtherTiedSongs
Dim IndexForAdding, OriginalOrder
IndexForAdding = SDB.Player.CurrentSongIndex
OriginalOrder = SDB.Player.CurrentSong.TrackOrder
Dim MySongs
' For MM2
Set MySongs = SDB.Database.QuerySongs("AND Songs.Custom3='" & DoubleUpSingleQuotes(SDB.Player.CurrentSong.Custom3) & "' ORDER BY Songs.SongOrder ASC")
' For MM3
' Set MySongs = SDB.Database.QuerySongs("Songs.Custom3='" & DoubleUpSingleQuotes(SDB.Player.CurrentSong.Custom3) & "' ORDER BY Songs.TrackNumber ASC")
If MySongs.EOF Then
RestoreSavedPlayerStates
Exit Sub
End If
SDB.Player.Previous
Do While Not MySongs.EOF
if MySongs.Item.TrackOrder < OriginalOrder then
SDB.Player.PlaylistAddTrack MySongs.Item
SDB.Player.PlaylistMoveTrack SDB.Player.PlaylistCount - 1, IndexForAdding
IndexForAdding = IndexForAdding + 1
end if
if MySongs.Item.TrackOrder > OriginalOrder then
IndexForAdding = IndexForAdding + 1
SDB.Player.PlaylistAddTrack MySongs.Item
SDB.Player.PlaylistMoveTrack SDB.Player.PlaylistCount - 1, IndexForAdding
end if
MySongs.Next
Loop
SDB.Player.Next
End Sub
Sub RestoreSavedPlayerStates
SDB.Player.isAutoDJ = StringToBool(SDB.IniFile.StringValue("Player", "saved_isAutoDJ"))
SDB.Player.isShuffle = StringToBool(SDB.IniFile.StringValue("Player", "saved_isShuffle"))
SDB.Player.isRepeat = StringToBool(SDB.IniFile.StringValue("Player", "saved_isRepeat"))
SDB.IniFile.StringValue("Player", "saved_hasBeenSaved") = "False"
End Sub
Sub PlayerStatesAsContinuous
SDB.Player.isAutoDJ = False
SDB.Player.isShuffle = False
SDB.Player.isRepeat = False
End Sub
Sub SavePlayerStates
SDB.IniFile.StringValue("Player", "saved_isAutoDJ") = SDB.Player.isAutoDJ
SDB.IniFile.StringValue("Player", "saved_isShuffle") = SDB.Player.isShuffle
SDB.IniFile.StringValue("Player", "saved_isRepeat") = SDB.Player.isRepeat
End Sub
Function StringToBool(InpuString)
If InpuString = "True" Then
StringToBool = True
Else
StringToBool = False
End If
End Function
' Doubles single quotes so SQL doesn't have problems with it anymore
Function DoubleUpSingleQuotes(strInput)
DoubleUpSingleQuotes = Replace(strInput, "'", "''")
End Function
Code: Select all
'=============================================================================================
'
' MediaMonkey Script
'
' NAME: Link selected tracks - put link value in Custom 3
'
' AUTHOR: Rycher
' DATE : 16/06/2008
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini
' Don't forget to remove comments (') and set the order appropriately
'
' [LinkTracksInCustom3]
' FileName=LinkTracksInCustom3.vbs
' ProcName=LinkTracksInCustom3
' Order=10
' DisplayName=&Link selected tracks
' Description=Link selected tracks - put link value in Custom 3
' Language=VBScript
' ScriptType=0
'
'=============================================================================================
' A simple script that set the Custom3 field of all selected tracks with a common tag
Sub LinkTracksInCustom3
' Get list of selected tracks from MediaMonkey
Dim list : Set list = SDB.CurrentSongList
If list.Count = 0 Then
Call SDB.MessageBox("No tracks are selected.",mtInformation,Array(mbOk))
Exit Sub
End If
' Define variables
Dim i, Tag
Tag = "LT_"+list.Item(0).AlbumName+"_"+list.Item(0).Title
' Process all selected tracks
For i=0 To list.count-1
list.Item(i).Custom3 = Tag
Next
' Write all back to DB and update tags
list.UpdateAll
End Sub
Excellent! Thanks a lot!trixmoto wrote:In the "Scripts.ini" file under the "[LinkTracksInCustom3]" section add a line like...
Shortcut=Ctrl+Shift+T
...then restart MM and try it out!