by Gingernut63 » Sat Nov 10, 2012 7:19 pm
Peke wrote:Hi, I was not being able to replicate using MM script to change/add/remove tracks from now playing. Events are triggered correctly. Can you make MM script that triggers issue?
Thanks for the reply Peke.
I've included the following code which is a section of the MonkeySqueeze script. the full script is found here:
http://www.mediamonkey.com/forum/viewto ... 45#p333888
Code: Select all
'borrowed from a teknojunky - if you want the popups add them to this and then just call logme
Sub logme(msg)
Dim fso, logf
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set logf = fso.OpenTextFile(Script.ScriptPath&".log",ForAppending,True)
logf.WriteLine Now() & ": " & msg
Set fso = Nothing
Set logf = Nothing
End Sub
'*************************************************************
'Perl is taking the JSON strings directly into variables - "\" is a special character in perl to escape the following string
'wherever we have a "\" we need it to be "\\" in anything that goes to Perl (ie: anything that goes to SqueezeBox)
Function perlEscape(str1)
perlEscape = Replace(str1, "\", "\\")
End Function
'*************************************************************
Sub registerEvents
Call Script.RegisterEvent(SDB,"OnPlay","Event_OnPlay")
Call Script.RegisterEvent(SDB,"OnPause","Event_OnPause")
Call Script.RegisterEvent(SDB,"OnStop","Event_OnStop")
Call Script.RegisterEvent(SDB,"OnSeek","Event_OnSeek")
Call Script.RegisterEvent(SDB,"OnTrackEnd","Event_OnTrackEnd")
Call Script.RegisterEvent(SDB,"OnShutdown","Event_OnShutdown")
Call Script.RegisterEvent(SDB,"OnNowPlayingModified","Event_OnNowPlayingModified")
End Sub
'*************************************************************
Sub Event_OnNowPlayingModified
Dim MMcount
MMcount = SDB.Player.CurrentPlayList.Count
logme("Now playing modified")
logme("Aantal MM tracks: " & Cstr(MMcount))
logme("Aantal LMS tracks: " & Cstr(LMScount))
If SqueezeBoxMode = "stop" Then
FillPlaylist
ElseIf MMcount = 0 Then
ResetPlaylist
ElseIf MMcount < LMScount Then
TracksDeleted(MMcount)
ElseIf MMcount > LMScount Then
TracksAdded(MMcount)
Else
TracksMoved
End If
End Sub
Using the log function in the script while modifying the track list in Now Playing via the MM GUI returned the following values which indicate tracks being deleted. MonkeySqueeze then operated correctly and sent the required changes to the Squeezebox system.
11/11/2012 8:01:36 AM: Now playing modified
11/11/2012 8:01:36 AM: Aantal MM tracks: 5
11/11/2012 8:01:36 AM: Aantal LMS tracks: 6
11/11/2012 8:02:08 AM: Now playing modified
11/11/2012 8:02:08 AM: Aantal MM tracks: 4
11/11/2012 8:02:08 AM: Aantal LMS tracks: 5
Using the Monkeytunes/TunesRemote+ app to add tracks resulted in the tracks appearing in the MM Now Playing window but no activity was recorded in the log file and hence no interaction with MonkeySqueeze. The "OnNowPlayingModified" event did not note any activity. Play, stop, pause etc... work without a problem however.
[quote="Peke"]Hi, I was not being able to replicate using MM script to change/add/remove tracks from now playing. Events are triggered correctly. Can you make MM script that triggers issue?[/quote]
Thanks for the reply Peke.
I've included the following code which is a section of the MonkeySqueeze script. the full script is found here: http://www.mediamonkey.com/forum/viewtopic.php?f=19&t=59907&start=45#p333888
[code]'borrowed from a teknojunky - if you want the popups add them to this and then just call logme
Sub logme(msg)
Dim fso, logf
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set logf = fso.OpenTextFile(Script.ScriptPath&".log",ForAppending,True)
logf.WriteLine Now() & ": " & msg
Set fso = Nothing
Set logf = Nothing
End Sub
'*************************************************************
'Perl is taking the JSON strings directly into variables - "\" is a special character in perl to escape the following string
'wherever we have a "\" we need it to be "\\" in anything that goes to Perl (ie: anything that goes to SqueezeBox)
Function perlEscape(str1)
perlEscape = Replace(str1, "\", "\\")
End Function
'*************************************************************
Sub registerEvents
Call Script.RegisterEvent(SDB,"OnPlay","Event_OnPlay")
Call Script.RegisterEvent(SDB,"OnPause","Event_OnPause")
Call Script.RegisterEvent(SDB,"OnStop","Event_OnStop")
Call Script.RegisterEvent(SDB,"OnSeek","Event_OnSeek")
Call Script.RegisterEvent(SDB,"OnTrackEnd","Event_OnTrackEnd")
Call Script.RegisterEvent(SDB,"OnShutdown","Event_OnShutdown")
Call Script.RegisterEvent(SDB,"OnNowPlayingModified","Event_OnNowPlayingModified")
End Sub
'*************************************************************
Sub Event_OnNowPlayingModified
Dim MMcount
MMcount = SDB.Player.CurrentPlayList.Count
logme("Now playing modified")
logme("Aantal MM tracks: " & Cstr(MMcount))
logme("Aantal LMS tracks: " & Cstr(LMScount))
If SqueezeBoxMode = "stop" Then
FillPlaylist
ElseIf MMcount = 0 Then
ResetPlaylist
ElseIf MMcount < LMScount Then
TracksDeleted(MMcount)
ElseIf MMcount > LMScount Then
TracksAdded(MMcount)
Else
TracksMoved
End If
End Sub
[/code]
Using the log function in the script while modifying the track list in Now Playing via the MM GUI returned the following values which indicate tracks being deleted. MonkeySqueeze then operated correctly and sent the required changes to the Squeezebox system.
[quote]11/11/2012 8:01:36 AM: Now playing modified
11/11/2012 8:01:36 AM: Aantal MM tracks: 5
11/11/2012 8:01:36 AM: Aantal LMS tracks: 6
11/11/2012 8:02:08 AM: Now playing modified
11/11/2012 8:02:08 AM: Aantal MM tracks: 4
11/11/2012 8:02:08 AM: Aantal LMS tracks: 5[/quote]
Using the Monkeytunes/TunesRemote+ app to add tracks resulted in the tracks appearing in the MM Now Playing window but no activity was recorded in the log file and hence no interaction with MonkeySqueeze. The "OnNowPlayingModified" event did not note any activity. Play, stop, pause etc... work without a problem however.