Page 1 of 8
LinkedTracks v1.1.1 [MM2+3+4] (TSFKA TiedSongsGroups)
Posted: Tue Feb 28, 2006 9:21 am
by Steegy
:: Script LinkedTracks v1.1.1 (TiedSongsGroups)
This script lets you link tracks together in a group, so when one track of the group is played, the previous & next tracks in the group are also added for playback (in order, if they weren't already there). Optionally the player will always jump to the first track in the group and start playing from there continuously till the last track in the group.
The idea came from
here.
Installation Package: LinkedTracks111.mmip
How to use:
- Select the tracks in the main tracklist that you want to link, right-click and choose "Link selected tracks" (Shift+Ctrl+L).
- Add e.g. one of the linked songs to the now playing list.
- When playback starts on the added song, notice that the other songs of the group will be added before/after.
- Depending on the options (menu Tools > Options > Player > Linked Tracks), playback will start from the added song or from the first song in the group, till the last one in the group, and this in continuous mode (independant of how shuffle, auto-dj, ... was set before).
- When the last song in the group is played, the player continues with the other songs in the now playing list (restoring shuffle, auto-dj, ...).
Note: By default, the 'link' between the linked tracks will be stored in the tracks' Custom5 field. This can be changed in the settings (e.g. if you are already using this field for another purpose).
Version 1.1 of the script now called LinkedTracks (indeed sounds better than TiedSongsGroups) is, simply put, a combination of the different versions (Steegy, das Monkey, Rycher) posted in this thread by the different authors. It has the option panel to change the script's configuration, and the context menu item to create a group with the selected songs.
As always feel free to update the script and put the installation package online. Then me or a moderator can update this first post to reference the new version.
Attention: This script is NOT the DJTiedSongsGroups. The last version of Rycher's DJTiedSongsGroups script can be found
here.
Posted: Tue Feb 28, 2006 10:37 am
by Lowlander
Does it also add previous songs tied to the song, ie songs with a lower track number?
Posted: Tue Feb 28, 2006 1:18 pm
by Steegy
No it doesn't for now, as the script was made "on request" just to add the following tracks.
But I think that can be easily added, as an option to choose. Anyway, I'll try...
BTW: I forgot to mention where the idea came from; I'll add a link to the request thread right away.
ADDITION: Before I implement the suggestion to also add previous songs from the same group, can anyone please give an example of a case in which this would be useful.
Maybe it would make sense to make the script begin playing at the beginning of the group whenever one song would be played?
Now: if song 5 (of 1 to 9) is in the playlist and would start playback, now it adds songs 6 to 9 after it, and then plays these in ordered way. Once the last song (9) is played, the playlist returns to the previous state (e.g. shuffle or auto-dj, if there were active).
This new proposal would add 1 to 4 before, and 6 to 9 after track 5, and the playback would start from 1 and go continuously to 9, after that, the normal now playing behaviour continues.
Would you like this?
(this feature looks only useful to me if the playback starts from the first track (1), instead of continuing as it would, with track 5 (because the added songs 1 to 4 wouldn't be played otherwise).)
(Just to avoid me doing unnecessary things...)
Cheers
Steegy
Posted: Wed Mar 01, 2006 4:20 am
by trixmoto
I didn't realise methods for switching on/off shuffle were accessible already. Nice one!
Posted: Wed Mar 01, 2006 4:38 am
by Guest
I'm confused.
i already did this with auto playlists?
i added some stuff in to the custom field i wanted it in.
on all the songs i wanted it in. then made the auto playlist look for that stuff in that field.
it gathers all the songs that have that stuff in the custom field?
why is there need for a script. i don't understand this need?
roving cowboy / keith hall
just riding the fence line again.
Posted: Wed Mar 01, 2006 4:48 am
by Guest
please disreguard my other post.
i have been reading and reading this.
i know now what this will be good at doing.
Example.
some one has a new computer that will not handle large files like one hour or longer concert wav files.
so instead of using the wav editor and putting all the wav's back together as one long wav file.
this script would allow all the files of concert sections to be played in order with out having to merge them back in to one file.
this is also handy for use with classical symphony's where they are broken in to segments and sometimes only one segment is recorded by one orchestra, in which you would need to gather all parts up from the different conductors so you could hear the complete symphony.
roving cowboy / keith hall
riding the fence line is tiresome and makes you not read things right the first time.
Posted: Wed Mar 01, 2006 5:05 am
by Steegy
Indeed, please also read
http://www.mediamonkey.com/forum/viewtopic.php?t=8404 if you want more information.
Posted: Sun Feb 17, 2008 3:35 pm
by Just JP
As mentioned in
another post, could this script be made MM3 compatible.
Jim
Posted: Sun Feb 17, 2008 4:39 pm
by Bex
This should do it.
Replace line 96.
From:
Code: Select all
Set MySongs = SDB.Database.QuerySongs("AND Songs.Custom3='" & DoubleUpSingleQuotes(SDB.Player.CurrentSong.Custom3) & "' AND Songs.SongOrder >= " & SDB.Player.CurrentSong.TrackOrder & " ORDER BY Songs.SongOrder ASC")
To:
Code: Select all
Set MySongs = SDB.Database.QuerySongs("Songs.Custom3='" & DoubleUpSingleQuotes(SDB.Player.CurrentSong.Custom3) & "' AND Songs.TrackNumber > '" & SDB.Player.CurrentSong.TrackOrderStr & "' ORDER BY Songs.TrackNumber ASC")
Not tested...
Posted: Sun Feb 17, 2008 9:36 pm
by Just JP
WOW, that was quick.
I'll have to give it a try and see what happens. Thanks.
Jim
Posted: Mon Feb 18, 2008 4:45 am
by Dreadlau
MMMh I will have to try this when I get home
Posted: Mon Feb 18, 2008 7:04 am
by das Monkey
It works. I made some modifications for me personally, namely a configuration screen where I can select which Custom field to use (in case 3 is used for something else) and enable/disable Crossfading between linked tracks. It's unlikely anyone would ever want linked tracks of this nature to Crossfade, so it seemed a logical addition.
One issue to consider: if you quit MediaMonkey before the last track in a group has been loaded, you'll lose your AutoDJ, Shuffle, and Repeat settings (and in my case, Crossfade). They're simple toggles, so it's not a big deal, but just be aware of that possibility.
Anyway, many thanks for the script, Steegy!
das
Posted: Fri Feb 22, 2008 5:35 pm
by Just JP
I finally got around to installing the updated version of this script and it works perfectly.
Thanks to Steegy for writing the original script and to Bex for making it work in MM3.
Jim
Posted: Wed Feb 27, 2008 4:25 pm
by Dreadlau
@Das Monkey.
Care to share your mod? Would be apraciated.
Thanks
Posted: Thu Feb 28, 2008 11:37 am
by das Monkey
I don't mind sharing my code, but all I did was plagiarize
Steegy's original hard work and rename things more logically for my setup. Furthermore, I borrowed the config screen coordinates and translation code from something else in my scripts directory (I don't recall which script now). I hope it's not stepping on any toes to post it. The original work and inspiration are not mine, and all credit belongs to other people.
First, in /Scripts/Auto/ I created a file called LinkedTracks.vbs (I changed the name because it made more sense to me that way and I didn't want to confuse my code with the original):
Code: Select all
Sub OnStartUp
Dim i : i = SDB.UI.AddOptionSheet("Linked Tracks", Script.ScriptPath, "InitSheet", "SaveSheet", -2)
End Sub
Sub InitSheet(Sheet)
Dim UI : Set UI = SDB.UI
Dim ini : Set ini = SDB.IniFile
Dim Label1 : Set Label1 = UI.NewLabel(Sheet)
Label1.Alignment = 1
Label1.Autosize = False
Label1.Common.SetRect 5,10,130,18
Label1.Common.ControlName = "CustomLabel"
Label1.Caption = Translate("Custom Field") & ":"
Dim DropDown1 : Set DropDown1 = UI.NewDropDown(Sheet)
DropDown1.Style = 2
DropDown1.Common.SetRect 140,6,200,21
DropDown1.Common.ControlName = "CustomField"
DropDown1.AddItem(CustomField(1))
DropDown1.AddItem(CustomField(2))
DropDown1.AddItem(CustomField(3))
DropDown1.AddItem(CustomField(4))
DropDown1.AddItem(CustomField(5))
DropDown1.ItemIndex = ini.IntValue("LinkedTracks", "CustomField")
Dim Checkbox1 : Set Checkbox1 = UI.NewCheckbox(Sheet)
Checkbox1.Common.SetRect 110,50,250,18
Checkbox1.Common.ControlName = "DisableCrossFade"
Checkbox1.Caption = "Disable Crossfade between linked tracks"
Checkbox1.Checked = ini.BoolValue("LinkedTracks", "DisableCrossFade")
End Sub
Sub SaveSheet(Sheet)
Dim ini : Set ini = SDB.IniFile
ini.IntValue("LinkedTracks", "CustomField") = Sheet.Common.ChildControl("CustomField").ItemIndex
ini.BoolValue("LinkedTracks", "DisableCrossFade") = Sheet.Common.ChildControl("DisableCrossFade").Checked
End Sub
Function Translate(str)
Translate = str
Dim dic : Set dic = SDB.Objects("LyrDict")
If Not (dic Is Nothing) Then
If dic.Exists(str) Then
Translate = dic.Item(str)
End If
End If
End Function
Function CustomField(i)
CustomField = SDB.IniFile.StringValue("CustomFields","Fld" & i & "Name")
End Function
If you go to Tools/Options/Player/Linked Tracks, you can select which Custom Field. It should pull the names of the fields from Library/Appearance if you've changed them. There's also a simple checkbox for whether or not to disable crossfading. It defaults to false.
In Scripts.ini, I added this:
Code: Select all
[LinkedTracks]
FileName=LinkedTracks.vbs
ProcName=LinkTracks
Order=1
Language=VBScript
ScriptType=2
And in the main /Scripts/ directory, I created another file called LinkedTracks.vbs (yeah, I named it the same thing -- sorry, I guess that's confusing
I wasn't expecting to share it.):
Code: Select all
Sub LinkTracks
Dim ini : Set ini = SDB.IniFile
Dim CustomField : CustomField = ini.IntValue("LinkedTracks", "CustomField")
Dim CurrentCustom, NextCustom
Select Case CustomField
Case 0: CurrentCustom = SDB.Player.CurrentSong.Custom1
Case 1: CurrentCustom = SDB.Player.CurrentSong.Custom2
Case 2: CurrentCustom = SDB.Player.CurrentSong.Custom3
Case 3: CurrentCustom = SDB.Player.CurrentSong.Custom4
Case 4: CurrentCustom = SDB.Player.CurrentSong.Custom5
End Select
If SDB.Player.CurrentSongIndex + 1 < SDB.Player.PlaylistCount Then
Select Case CustomField
Case 0: NextCustom = SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1).Custom1
Case 1: NextCustom = SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1).Custom2
Case 2: NextCustom = SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1).Custom3
Case 3: NextCustom = SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1).Custom4
Case 4: NextCustom = SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1).Custom5
End Select
End If
If Left(CurrentCustom, 3) = "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
Call AddOtherTiedSongs(CurrentCustom)
Else
If NextCustom <> CurrentCustom Or SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1).TrackOrder > CurrentCustom Then
'Non-tied song comes after
Call AddOtherTiedSongs(CurrentCustom)
Else
'Tied song comes after
PlayerStatesAsContinuous
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(CurrentCustom)
Dim ini : Set ini = SDB.IniFile
Dim IndexForAdding
IndexForAdding = SDB.Player.CurrentSongIndex
Dim MySongs
Set MySongs = SDB.Database.QuerySongs("Songs.Custom" & CInt(ini.IntValue("LinkedTracks", "CustomField")) + 1 & "='" & DoubleUpSingleQuotes(CurrentCustom) & "' AND Songs.TrackNumber > '" & SDB.Player.CurrentSong.TrackOrderStr & "' ORDER BY Songs.TrackNumber ASC")
If MySongs.EOF Then
RestoreSavedPlayerStates
End If
Do While Not MySongs.EOF
IndexForAdding = IndexForAdding + 1
SDB.Player.PlaylistAddTrack MySongs.Item
SDB.Player.PlaylistMoveTrack SDB.Player.PlaylistCount - 1, IndexForAdding
MySongs.Next
Loop
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.Player.isCrossfade = StringToBool(SDB.IniFile.StringValue("Player", "saved_isCrossfade"))
SDB.IniFile.StringValue("Player", "saved_hasBeenSaved") = "False"
End Sub
Sub PlayerStatesAsContinuous
Dim ini : Set ini = SDB.IniFile
Dim DisableCrossFade : DisableCrossFade = ini.BoolValue("LinkedTracks", "DisableCrossFade")
SDB.Player.isAutoDJ = False
SDB.Player.isShuffle = False
SDB.Player.isRepeat = False
If DisableCrossFade Then
SDB.Player.isCrossfade = False
End If
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
SDB.IniFile.StringValue("Player", "saved_isCrossfade") = SDB.Player.isCrossfade
End Sub
Function StringToBool(InpuString)
If InpuString = "True" Then
StringToBool = True
Else
StringToBool = False
End If
End Function
Function DoubleUpSingleQuotes(strInput)
DoubleUpSingleQuotes = Replace(strInput, "'", "''")
End Function
I changed the "TG" prefix to "LT_", again to avoid potential confusion.
99% of this code is the work of others. I just tweaked it around to fit my needs.
das