LinkedTracks v1.1.1 [MM2+3+4] (TSFKA TiedSongsGroups)

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

Moderators: Peke, Gurus

rrfpacker
Posts: 1065
Joined: Sat Jul 12, 2008 5:47 pm

Re: TiedSongsGroups: lets you make tied groups of songs

Post by rrfpacker »

I just found this script and would like to know if it really works with MM3, the last response by the developer was back in March 2009 and noone has answered the latest post.

And if it does work, can someone tell us exactly what to do to make it work? Thank you.
nohitter151
Posts: 23640
Joined: Wed Aug 09, 2006 10:20 am
Location: NJ, USA
Contact:

Re: TiedSongsGroups: lets you make tied groups of songs

Post by nohitter151 »

rrfpacker wrote:I just found this script and would like to know if it really works with MM3, the last response by the developer was back in March 2009 and noone has answered the latest post.

And if it does work, can someone tell us exactly what to do to make it work? Thank you.
It should work, you need to edit the script though. It's described in this post: http://www.mediamonkey.com/forum/viewto ... 82#p131782
MediaMonkey user since 2006
Need help? Got a suggestion? Can't find something?

Please no PMs in reply to a post. Just reply in the thread.
rrfpacker
Posts: 1065
Joined: Sat Jul 12, 2008 5:47 pm

Re: TiedSongsGroups: lets you make tied groups of songs

Post by rrfpacker »

Thanks nohitter,

But does that mean that if I use the script on page 4 (to be used with AutoDJ) that I don't have to do that?
nohitter151
Posts: 23640
Joined: Wed Aug 09, 2006 10:20 am
Location: NJ, USA
Contact:

Re: TiedSongsGroups: lets you make tied groups of songs

Post by nohitter151 »

rrfpacker wrote:Thanks nohitter,

But does that mean that if I use the script on page 4 (to be used with AutoDJ) that I don't have to do that?
I would certainly guess so since that was posted well after the original "fix" post.
MediaMonkey user since 2006
Need help? Got a suggestion? Can't find something?

Please no PMs in reply to a post. Just reply in the thread.
EinsteinX
Posts: 31
Joined: Thu Feb 04, 2010 2:29 pm

Re: TiedSongsGroups: lets you make tied groups of songs

Post by EinsteinX »

rrfpacker wrote:Thanks nohitter,

But does that mean that if I use the script on page 4 (to be used with AutoDJ) that I don't have to do that?
I'm using MM 3.2.1.1297 and the script I'm using is working fine. It's called "DJTiedSongsGroups.vbs"

You need to add this to your "Scripts.ini" file:

Code: Select all

[DJTiedSongsGroups]
 FileName=DJTiedSongsGroups.vbs
 DisplayName=AutoDJ Tied songs groups
 Language=VBScript
 ScriptType=4
And this is the scrips for the DJTiedSongsGroups:

Code: Select all

    '==========================================================================
    '
    ' MediaMonkey Script
    '
    ' NAME: DJTiedSongsGroups
    ' DESCRIPTION:
    '  Lets you use auto-dj while playing together groups of songs that should go together
    '  (groups of songs must previously be tagged as linked)
    '
    ' AUTHOR: Tanguy Kervahut
    ' DATE  : 11.10.2008
    '
    ' INSTALL:
    ' - Copy script to MediaMonkey's "Scripts" folder
    ' - Add an script entry to file Scripts.ini (example shown below)
    '
    ' USE:
    ' For songs you want in one group, change the Custom3 field for these songs to
    '  the same value, beginning with LT (this indicates a "linked track").
    ' E.g. for an album "Pink Floyd - Dark Side of the Moon" you can change the Custom3 field
    '  for all tracks to "LT Pink Floyd - Dark Side of the Moon". (without quotation marks).
    ' Bear in mind that shorter values for the Custom3 field are faster (so better "LT PF-DSOTM")
    ' Order of tracks in a tied group is indicated using the standard Track Number field.
    '
    ' [DJTiedSongsGroups]
    ' FileName=DJTiedSongsGroups.vbs
    ' DisplayName=AutoDJ Tied songs groups
    ' Language=VBScript
    ' ScriptType=4

    '##############################################################################################

    Option Explicit

    Public TagGroupPlaylist, LastSong

    Sub InitConfigSheet(Panel)
      Dim Edt, Lists, i
     
      Set Edt = SDB.UI.NewLabel(Panel)
      Edt.Common.SetRect 1, 1, 75, 20
      Edt.Caption = "Use playlist:"
      Edt.Autosize = False
      Edt.Alignment = 0

      Set Edt = SDB.UI.NewDropDown(Panel)
      Set Lists = SDB.PlaylistByTitle("").ChildPlaylists
      for i = 0 to Lists.Count-1
         Edt.AddItem(Lists.Item(i).Title)
      next
      Edt.Common.SetRect 86, 1, 200, 20
      Edt.Common.ControlName = "TagGroupPlaylist"
      Edt.Text = SDB.IniFile.StringValue("TagGroup", "DefaultPlaylist")
    End Sub


    Sub CloseConfigSheet(Panel, SaveConfig)
      if Saveconfig then
         SDB.IniFile.StringValue("TagGroup", "DefaultPlaylist") = Panel.Common.ChildControl("TagGroupPlaylist").Text
      end if
    End Sub


    Function GenerateNewTrack
      Dim LastGroup, NextSong, NextFound

      NextFound = false
     
      if isEmpty(LastSong) then
        Randomize
        if SDB.Player.PlaylistCount > 0 then
          Set LastSong = SDB.Player.PlaylistItems(SDB.Player.PlaylistCount - 1)
        end if
      end if
     
      if NOT isEmpty(LastSong) then
        If Left(LastSong.Custom3, 2) = "LT" Then
          Set LastGroup = SDB.Database.QuerySongs("Songs.Custom3='" & LastSong.Custom3 & "' ORDER BY abs(Songs.TrackNumber) ASC")
     
          Do While Not LastGroup.EOF
            if LastGroup.Item.TrackOrder > LastSong.TrackOrder then
              Set NextSong = LastGroup.Item
             NextFound = true
                exit do
            end if
            LastGroup.Next
          Loop
        end if
      end if
     
      If NextFound Then
        Set LastSong = NextSong
       Set GenerateNewTrack = NextSong
      else
        Dim CheckPlaylist, RandomTrack, i
       
       TagGroupPlaylist = SDB.IniFile.StringValue("TagGroup", "DefaultPlaylist")
        Set CheckPlaylist = SDB.PlaylistByTitle(TagGroupPlaylist).Tracks
       i = 0
       Do
         RandomTrack = Int(Rnd() * CheckPlaylist.Count)
         Set NextSong = CheckPlaylist.Item(RandomTrack)
         i = i + 1
       Loop while (IsInSongList(NextSong, SDB.Player.CurrentPlaylist) Or SameGroup(NextSong, LastSong)) AND i < CheckPlaylist.Count
       
       If Left(NextSong.Custom3, 2) = "LT" Then
          Set LastGroup = SDB.Database.QuerySongs("Songs.Custom3='" & NextSong.Custom3 & "' ORDER BY abs(Songs.TrackNumber) ASC")
          Set LastSong = LastGroup.Item
          Set GenerateNewTrack = LastGroup.Item
        else
          Set LastSong = NextSong
          Set GenerateNewTrack = NextSong
       end if
      End If
     
    End Function


    Function IsInSongList( Song, List )
      Dim i
       
      IsInSongList = False
      if not isEmpty(Song) AND List.Count > 0 then
      for i = 0 to List.Count -1
        if List.Item(i).SongId = Song.SongId then
         IsInSongList = True
         exit for
       end if
      next
      end if
       
    End Function

    Function SameGroup( Song1, Song2 )
      if isEmpty(Song1) or isEmpty(Song2) then
        SameGroup = False
      else   
        if Song1.SongId <> Song2.SongId AND (Left(Song1.Custom3, 2) <> "LT" OR Song1.Custom3 <> Song2.Custom3) then
          SameGroup = False
       else
          SameGroup = True
        end if
      end if
       
    End Function

You need to add this "DJTiedSongsGroups.vbs" script file to C:\Program Files\MediaMonkey\Scripts.

Hope this helps,

Eins
Espan

Re: TiedSongsGroups: lets you make tied groups of songs

Post by Espan »

Does anyone know if MM plans on integrating this in a future release? It's a very helpful script/function... Thanks to all the programmers for time/effort/work
rycher
Posts: 129
Joined: Mon Sep 11, 2006 8:24 pm

Re: TiedSongsGroups: lets you make tied groups of songs

Post by rycher »

I've installed MM4, and this script does not work anymore. Basically, the custom config is not available anymore in the Auto-DJ options. I didn't see anything about changes to script handling for MM4 that would affect this. My other scripts work, but those are normal scripts triggered through the menu, not hooks on an internal function like this one.
Does anyone know what changed? If not I'll raise an issue about this.
Thanks!
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Re: LinkedTracks v1.1 [MM2+3+4] (TSFKA TiedSongsGroups)

Post by Steegy »

Hi Rycher,

Current MM4 developer builds might have problems with the "Auto-DJ" (4) and "OnPlay" (2) type entries in the Scripts.ini file.
When I tested the TiedSongsGroups (not your AutoDJ version) on MM4, I think it didn't work either (uses Scripts.ini Type 2). But I'm not sure as I updated some things in the script, including using the newer event model Script.RegisterEvent... and with that it certainly works. Have you tried other Auto-DJ scripts on MM4?

BTW: It would be great if you could put your DJTiedSongsGroups script in a MM installation package, so it can be put on the first post of this thread (or another thread if you prefer that).

Cheers,
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
rycher
Posts: 129
Joined: Mon Sep 11, 2006 8:24 pm

Re: LinkedTracks v1.1 [MM2+3+4] (TSFKA TiedSongsGroups)

Post by rycher »

I haven't had a lot of time for this recently, but I want to have a closer look at all this and make it work in MM4. Once I have a running version, I'll make a MM installation package for it (remind me if I forget :wink: ).
rycher
Posts: 129
Joined: Mon Sep 11, 2006 8:24 pm

Re: LinkedTracks v1.1 [MM2+3+4] (TSFKA TiedSongsGroups)

Post by rycher »

Ok, forget what I said, I must be more tired than I thought... It's been running by itself in MM3 for so long that I forgot how it was configured in the options.
I forgot that I had to select my script in "Add files from", I thought that it would automatically be setup because of the script :oops:

Seems to be working ok. Now back to your regularly scheduled program...
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Re: LinkedTracks v1.1 [MM2+3+4] (TSFKA TiedSongsGroups)

Post by Steegy »

Possible improvements as discussed with daztrue over PM:
daztrue wrote:The first time one of the 'generated' tracks was selected it played from that point onwards. It was probably a gremlin in the works as it didn't happen again - although I'll let you know if I detect any pattern or further occurances.
Yes, for now the script works like that. It just looks if the 1 track before and the 1 track after are OK (previous and next track in the set, or medley in your case) and then starts playback of the selected song without starting from the beginning (which happens only if linked tracks before had to be added because the 1 track before was not correct).
Like you suggest, better would be that the script stores the 'link' (blank for non-linked songs) of each track that starts playback, and compare with the 'link' of the next song that starts playback. When a song starts playing that has a different 'link', it should jump to the first song of the set: the script would 'run up' in the now playing list until it reaches the first song in the set and start playing, or if the set is incomplete it should add the necessary songs in front and start playing the first song (the last one added). By checking the 'link' of the previous song, it's still possible to manually skip playback to an other song in the set, once the set has started playing.
daztrue wrote:It'll be no surprise to you that when I randomised the list and a medley track was selected, the rest of the medley was added to the list again. I realise it would be far more complicated to remove the generated tracks when selecting randomise, although it's food for thought!
Probably the most logical approach in such a case would be an addition to the above. If a song starts playing with another 'link' than the previous played song, look if all previous and next linked tracks are present in the correct order in the now playing list. If not, (or this can also be done straight away, always) remove all the tracks in the now playing list that have that 'link', and re-add them in the correct order. Depends on how fast MM can do this of course.
daztrue wrote:The one other thing that would require more in-depth programming - again, food for thought - would be the benefit of the script not causing MM to lose memory of which tracks have been played in the list. Basically, what I observed (before repeatedly playing the list) was a shuffle play, of which the included medley track was the second to last to be selected, which, of course, generated the rest of the medley, which played accordingly, BUT afterwards I was expecting the one unplayed track in the Now Playing list to then play. But of course, as I explained before, the track after the medley then played, after which, tracks continued to be picked at random that had already played. Am I right in saying that without the script, a shuffled Now Playing list wouldn't have repeated already played tracks, thus memorising them until the list has finished?
Hmm, I'm not sure, but I think MM should work like you say. I'll try with and without the script and if the script changes the behaviour I'll think about a fix. I think MediaMonkey uses it's playback memory now for the shuffle mode...(which is great to avoid hearing the same 'random' song every time). If necessary we can add/remove tracks from MM's playback memory (in its database) automatically I guess. Just care should be taken that the playback statistics/history change as little as possible, as other scripts (Auto-DJ) probably heavilly rely on this.

Also to do: add icon IconIndex = 16 to context menu item + move the item 1 section up + add to context menu of Tree and NP.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
daztrue
Posts: 88
Joined: Fri Aug 27, 2010 5:47 am

Re: LinkedTracks v1.1.1 [MM2+3+4] (TSFKA TiedSongsGroups)

Post by daztrue »

Hi again!

Just had a thought. Wouldn't the script conflict with certain Playlists/AutoPlaylists? Obviously it would depend on the settings. I just wondered what would happen, how severe it may be etc. For example, a playlist set to only play R&B, and a selection of tracks using the script, predominately rock, but with one or more listed as R&B.
daztrue
Posts: 88
Joined: Fri Aug 27, 2010 5:47 am

Re: LinkedTracks v1.1.1 [MM2+3+4] (TSFKA TiedSongsGroups)

Post by daztrue »

FAO Steegy (although all comments welcome!):

I recently noticed that whenever I opened MM(3) shuffle would be on, and would turn on just as I exited. It wasn't happening in other Windows/MM accounts/libraries with the same setup. I even installed the debug version of MM on another PC and created the same setup, and found that the issue no longer occurred - until I installed LinkedTracks.

I checked one of my other accounts, which previously was fine, although now had tracks in it using LinkedTracks, thus the same scenario now occurs in that account/library.

As a reminder: my DB are on my NAS, and as of recently, so now are my INI files.

Any ideas why this is happening, whether you can sort it, and whether this function (one way or another) will feature in MM4?
rycher
Posts: 129
Joined: Mon Sep 11, 2006 8:24 pm

Re: LinkedTracks v1.1.1 [MM2+3+4] (TSFKA TiedSongsGroups)

Post by rycher »

Here is an update of the DJTiedSongsGroups script.

For a party I wanted to have some smooth music earlier in the evening, and switch to a rockier/dancier mood during the evening. But not have to go on the computer to change the source.

I've modified the script, now in the config window there is a field to specify a second source playlist, and a date time field (enter the date in format: 2011-11-23 18:10). The first playlist is used before the specified date/time, and after that time it switches to the second playlist (if one is specified).

NOTE: with MM4, there is a error that pops-up whenever multiple tracks are added at once (with the option By album or tagged tracks). Everything seems to work fine, but you get a pop-up message that you have to close. I've started a thread about that problem, no news yet on that.

Here is the updated script:

Code: Select all

'==========================================================================
'
' MediaMonkey Script
'
' NAME: DJTiedSongsGroups
' DESCRIPTION:
'  Lets you use auto-dj while playing together groups of songs that should go together
'  (groups of songs must previously be tagged as linked)
'
' AUTHOR: Tanguy Kervahut
' DATE  : 11.10.2008
'
' Modified: 29.10.2008
'    -Added "By album" option
'    -Change the mechanism, it now adds a whole group (or album) at once. So it can add more tracks than the maximum specified for auto-dj when
'      a group has more tracks than the maximum.
'
' Modified: 24.02.2009
'    -"By album" option now gives the same weight to all albums (before an album with more tracks had more chances to play)
'    -For multi-disc albums, ask if whole album should play or only selected disc.
'
' Modified: 17.03.2009
'    - Fix a small bug when tracks don't have track order
'
' Modified: 05.12.2011
'    - Added a second source playlist, and a date/time field after which the second playlist should be used.
'    - Date should be in format: 2011-11-23 18:10
'
' INSTALL:
' - Copy script to MediaMonkey's "Scripts" folder
' - Add an script entry to file Scripts.ini (example shown below)
'
' USE:
' For songs you want in one group, change the Custom3 field for these songs to
'  the same value, beginning with LT (this indicates a "linked track").
' E.g. for an album "Pink Floyd - Dark Side of the Moon" you can change the Custom3 field
'  for all tracks to "LT Pink Floyd - Dark Side of the Moon". (without quotation marks).
' Bear in mind that shorter values for the Custom3 field are faster (so better "LT PF-DSOTM")
' Order of tracks in a tied group is indicated using the standard Track Number field.
'
' [DJTiedSongsGroups]
' FileName=DJTiedSongsGroups.vbs
' DisplayName=AutoDJ Tied songs groups
' Language=VBScript
' ScriptType=4

'##############################################################################################

Option Explicit

Public DJTSG_LastSong, DJTSG_LastCall, DJTSG_NbAdded, Fso, LogF

Sub InitConfigSheet(Panel)
  Dim Edt, Lists, i

  Set Edt = SDB.UI.NewLabel(Panel)
  Edt.Common.SetRect 1, 5, 75, 20
  Edt.Caption = "Use playlist:"
  Edt.Autosize = False
  Edt.Alignment = 0

  Set Edt = SDB.UI.NewDropDown(Panel)
  Set Lists = SDB.PlaylistByTitle("").ChildPlaylists
  for i = 0 to Lists.Count-1
     Edt.AddItem(Lists.Item(i).Title)
  next
  Edt.Common.SetRect 76, 1, 200, 20
  Edt.Common.ControlName = "TagGroupPlaylist"
  Edt.Text = SDB.IniFile.StringValue("TagGroup", "DefaultPlaylist")

  Set Edt = SDB.UI.NewCheckBox(Panel)
  Edt.Common.SetRect 285, 2, 75, 20
  Edt.Common.ControlName = "ByAlbum"
  Edt.Caption = "By Album"
  Edt.Checked = SDB.IniFile.BoolValue("TagGroup", "ByAlbum")


  Set Edt = SDB.UI.NewLabel(Panel)
  Edt.Common.SetRect 1, 26, 75, 20
  Edt.Caption = "2nd playlist:"
  Edt.Autosize = False
  Edt.Alignment = 0

  Set Edt = SDB.UI.NewDropDown(Panel)
  for i = 0 to Lists.Count-1
     Edt.AddItem(Lists.Item(i).Title)
  next
  Edt.Common.SetRect 76, 22, 200, 20
  Edt.Common.ControlName = "TagGroupPlaylist2"
  Edt.Text = SDB.IniFile.StringValue("TagGroup", "DefaultPlaylist2")

  Set Edt = SDB.UI.NewEdit(Panel)
  Edt.Common.SetRect 285, 22, 125, 20
  Edt.Common.ControlName = "List2Time"
  Edt.Text = SDB.IniFile.StringValue("TagGroup", "List2Time")
End Sub


Sub CloseConfigSheet(Panel, SaveConfig)
  if Saveconfig then
     SDB.IniFile.StringValue("TagGroup", "DefaultPlaylist") = Panel.Common.ChildControl("TagGroupPlaylist").Text
     SDB.IniFile.StringValue("TagGroup", "DefaultPlaylist2") = Panel.Common.ChildControl("TagGroupPlaylist2").Text
     SDB.IniFile.StringValue("TagGroup", "List2Time") = Panel.Common.ChildControl("List2Time").Text
     SDB.IniFile.BoolValue("TagGroup", "ByAlbum") = Panel.Common.ChildControl("ByAlbum").Checked
  end if
End Sub

Function GenerateNewTrack
  Dim ByAlbum, TagGroupPlaylist, CheckPlaylist, i, RandomTrack, NextSong, NextGroup, DiscNo

' answer = SDB.MessageBox("Start of GenerateNewTrack", mtConfirmation, Array(mbYes,mbNo))

  if isEmpty(DJTSG_LastSong) then
    ' Randomize on first run
    Randomize
    DJTSG_NbAdded = 0
    DJTSG_LastCall = DateAdd("n",-1,Now)
  end if

  ' The following is to avoid adding multiple groups when more than one track needs
  ' to be added. Because MM can call this function multiple times at once when more
  ' than one is required to reach the minimum to maintain. When this happens, the
  ' playlist isn't updated until all calls are finished. So from an empty playlist,
  ' it could add 5 albums (if by album and number to maintain is 5).
  if DateDiff("s",DJTSG_LastCall,Now) < 5 then
    DJTSG_NbAdded = DJTSG_NbAdded - 1
    if DJTSG_NbAdded > 0 then
      exit Function
    end if
  else
    DJTSG_NbAdded = 0
  end if

  logme( "Inside GenerateNewTrack")

  Dim answer
  ByAlbum = SDB.IniFile.BoolValue("TagGroup", "ByAlbum")
  if (Len(SDB.IniFile.StringValue("TagGroup", "DefaultPlaylist2")) > 0) AND (Now > CDate(SDB.IniFile.StringValue("TagGroup", "List2Time"))) then
     TagGroupPlaylist = SDB.IniFile.StringValue("TagGroup", "DefaultPlaylist2")
  else
     TagGroupPlaylist = SDB.IniFile.StringValue("TagGroup", "DefaultPlaylist")
  end if
  Set CheckPlaylist = SDB.PlaylistByTitle(TagGroupPlaylist).Tracks
  if (CheckPlaylist.Count = 0) then
    ' To avoid multiple pop-up, see previous comment
    DJTSG_NbAdded = 99
    answer = SDB.MessageBox( "AutoDJ playlist is empty", mtError, Array(mbOk))
    exit Function
  end if

  i = 0
  if ByAlbum then
     dim CheckAlbumList, NextAlbum, RandomAlbum, AlbumTrackList
     Set CheckAlbumList = CheckPlaylist.Albums
     ' When ByAlbum, select an album at random from the AutoDJ playlist
     ' and not a track, otherwise albums with more tracks get picked more often
     Do
       RandomAlbum = Int(Rnd() * CheckAlbumlist.Count)
       Set NextAlbum = CheckAlbumlist.Item(RandomAlbum)
       Set AlbumTrackList = NextAlbum.Tracks
      Do
          RandomTrack = Int(Rnd() * AlbumTrackList.Count)
          Set NextSong = AlbumTrackList.Item(RandomTrack)
      Loop while (NOT IsInSongList(NextSong, CheckPlaylist)) ' Loop to skip discs already played from multi-disc albums
       i = i + 1
     Loop while (IsInSongList(NextSong, SDB.Player.CurrentPlaylist) Or SameGroup(NextSong, DJTSG_LastSong, ByAlbum)) AND i < CheckPlaylist.Count
  else
     Do
       RandomTrack = Int(Rnd() * CheckPlaylist.Count)
       Set NextSong = CheckPlaylist.Item(RandomTrack)
       i = i + 1
     Loop while (IsInSongList(NextSong, SDB.Player.CurrentPlaylist) Or SameGroup(NextSong, DJTSG_LastSong, ByAlbum)) AND i < CheckPlaylist.Count
  end if

  ' If you don't want to be asked what to play when it's a multi-disc album, simply replace the block below by: DiscNo = 0
  if (NextSong.TrackOrderStr <> "") then
     DiscNo = Fix(NextSong.TrackOrderStr / 100)
  else
     DiscNo = 0
  end if
  if (ByAlbum AND DiscNo > 0) then
    ' Ask to play full album or disc only
    answer = SDB.MessageBox( NextSong.AlbumArtistName & Chr(13) & NextSong.AlbumName & Chr(13) & Chr(13) & "Add full album? (No = Disc " & DiscNo & " only)", mtConfirmation, Array(mbYes,mbNo))
    if answer = mrYes then
      DiscNo = 0
    end if
  end if

  logme( "Track selected : " & NextSong.AlbumArtistName & " - " & NextSong.AlbumName & " - " & NextSong.Title )

  If ByAlbum OR Left(NextSong.Custom3, 2) = "LT" Then
    if ByAlbum then
      Set NextGroup = SDB.Database.QuerySongs("Songs.IDAlbum='" & NextSong.Album.Id & "' ORDER BY abs(Songs.TrackNumber) ASC")
    else
      Set NextGroup = SDB.Database.QuerySongs("Songs.Custom3='" & NextSong.Custom3 & "' ORDER BY abs(Songs.TrackNumber) ASC")
    end if
    ' Insert directly whole group at end of Now Playing - return nothing
    Set DJTSG_LastSong = NextGroup.Item
    Do While Not NextGroup.EOF
      dim NextNo
      Set NextSong = NextGroup.Item
      if NextSong.TrackOrderStr <> "" then
         NextNo = Fix(NextSong.TrackOrderStr / 100)
      else
         NextNo = 0
      end if

      NextGroup.Next

      if (NOT ByAlbum OR DiscNo = 0 OR NextNo = DiscNo ) then
        DJTSG_NbAdded = DJTSG_NbAdded + 1
        Call SDB.Player.PlaylistAddTrack( NextSong )
      end if
    Loop
  else
    ' Return track found
    DJTSG_NbAdded = DJTSG_NbAdded + 1
    Set GenerateNewTrack = NextSong
    Set DJTSG_LastSong = NextSong
  end if

  DJTSG_LastCall = Now

' answer = SDB.MessageBox("End of GenerateNewTrack", mtConfirmation, Array(mbYes,mbNo))

End Function


Function IsInSongList( Song, List )
  Dim i

  IsInSongList = False
  if not isEmpty(Song) AND List.Count > 0 then
  for i = 0 to List.Count -1
    if List.Item(i).SongId = Song.SongId then
      IsInSongList = True
      exit for
    end if
  next
  end if
End Function


Function SameGroup( Song1, Song2, ByAlbum )
  if isEmpty(Song1) or isEmpty(Song2) then
    SameGroup = False
  else
    if ByAlbum then
      SameGroup = Song1.Album.Id = Song2.Album.Id
    else
      SameGroup = Song1.SongId = Song2.SongId OR (Left(Song1.Custom3, 2) = "LT" AND Song1.Custom3 = Song2.Custom3)
    end if
  end if
End Function


Sub logme(msg)
' usage: logme( "text" & VarName )
' Don't forget to define LogF and Fso as Public
'  If DebugSt Then
    If IsEmpty(LogF) Then
      Set Fso = CreateObject("Scripting.FileSystemObject")
      Set LogF = Fso.OpenTextFile(Script.ScriptPath&".log",8,True)
    End If
    LogF.WriteLine Now() & ": " & msg
'  End If
End Sub
daztrue
Posts: 88
Joined: Fri Aug 27, 2010 5:47 am

Re: LinkedTracks v1.1.1 [MM2+3+4] (TSFKA TiedSongsGroups)

Post by daztrue »

rycher wrote:Here is an update of the DJTiedSongsGroups script.
Is this used instead of LinkedTracks or in conjunction with it? And does it make tracks play in a specific order just like LinkedTracks?
Post Reply