Accurate time synchronisation between devices

warwickwater

New Member
I need two Android devices (typically set top boxes, at opposite ends of a room) to play an audio file at exactly the same time (to avoid an 'echo' effect between them).

I realise I can get an accurate time of day using NTP - but how can I then accurately do something based on this time. Can I read the time of day to millisecond accuracy somewhere, or can I force a 'play sound' event to occur at exactly the same time (if I just repeatedly check the time of day, there will be some degree of error I assume?).

An obscure question I know, but my app depends on it 100%. Any thoughts, theories or suggestions very much appreciated.

(The devices will be connected to the public Internet using either mobile signal or wifi, possibly behind NAT firewallls etc, but they won't all necessarily be on the same LAN - so probably no scope for clever inter device communication)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
DateTime.Now will return the current time in milliseconds.

Though I'm not sure how will you set the time with that accuracy. It is not possible to set the time programmatically. You will need to somehow calculate the offset of each device. NTP will most probably not help with such accuracy as there are network latency and other causes that will make it a bit inaccurate.
 
Upvote 0
Top