I had a lot of trouble understanding how Enhanced Synchronization works in BrightScript so I'm sharing this code to help others who want to see a minimal example of how to use roSyncManager.
' LEADER - Minimum example of Enhanced Sync
' Based on: https://brightsign.atlassian.net/wiki/spaces/DOC/pages/370673205/roSyncManager
' - (Assumes that each player already has manual IP and PTP domain set in registry)
' - Insert your filename below!
print "ENHANCED SYNC TEST - LEADER"
' Create a sync manager with default address and port.
aa1=CreateObject("roAssociativeArray")
aa1.Domain = "BS1"
s=CreateObject("roSyncManager", aa1)
p=CreateObject("roMessagePort")
s.SetPort(p)
' Create a video player - we're going to play a seamlessly looped file
v=CreateObject("roVideoPlayer")
v.SetLoopMode(True)
' We're the leader unit - send out a synchronize event saying that we're starting.
' playback 1000ms from now
s.SetMasterMode(True) ' Docs say "SetLeaderMode" but "SetMasterMode" seems to be correct!
msg = s.Synchronize("Blah1", 1000) ' Blah1 is an optional "sync ID" payload to pass to the follower
aa=CreateObject("roAssociativeArray")
aa.Filename = "Sync Test 1 (30sec HD fixed PCM).mov"
aa.SyncDomain = msg.GetDomain()
aa.SyncId = msg.GetId()
aa.SyncIsoTimestamp = msg.GetIsoTimestamp()
ok = v.PlayFile(aa)
if ok then
print "Playing Video..."
end if
while true
' Nothing to do here! After the first synchronize is called, roSyncManager invisibly sends
' sync messages every sec, and the followers adjust playback to match. These messages don't
' seem to be of type roSyncManagerEvent and we can't detect them via BrightScript. They "just work".
end while
' FOLLOWER - Minimum example of Enhanced Sync
' Based on: https://brightsign.atlassian.net/wiki/spaces/DOC/pages/370673205/roSyncManager
' - (Assumes that each player already has manual IP and PTP domain set in registry)
' - Insert your filename below!
print "ENHANCED SYNC TEST - FOLLOWER"
' Create a sync manager with default address and port.
aa1=CreateObject("roAssociativeArray")
aa1.Domain = "BS1"
s=CreateObject("roSyncManager", aa1)
p=CreateObject("roMessagePort")
s.SetPort(p)
' Create a video player - we're going to play a seamlessly looped file
v=CreateObject("roVideoPlayer")
v.SetLoopMode(True)
While true
' Listen for explicit messages from leader script's roSyncManager.Synchronize
' Once playback begins, further messages are being sent every sec and the player
' will adjust to match, with no further script interaction.
msg=Wait(0, p)
if type(msg) = "roSyncManagerEvent" then
print "roSyncManagerEvent received..."
aa = CreateObject("roAssociativeArray")
aa.Filename = "Sync Test 1 (30sec HD fixed PCM).mov"
aa.SyncDomain = msg.GetDomain()
aa.SyncId = msg.GetId()
print "Payload = " + aa.SyncId 'The optional payload sent with the synchronize message
aa.SyncIsoTimestamp = msg.GetIsoTimestamp()
print "Timestamp = " + aa.SyncIsoTimestamp
ok = v.PlayFile(aa)
if ok then
print "roSyncManagerEvent updated video player"
end if
else
print "Other event received. Type:" + type(msg)
end if
End While
Disclaimer: This code is tested but I'm no expert! Hope it helps somebody.