keeping AirPlay active

We have a Mac connected to an Apple TV via ethernet. ( via AirPlay screen mirroring)

Sometimes the ethernet connection is interrupted for a few minutes and then it comes back

When this happen the Mac disconnects itself from the Apple TV

On the Mac we would like to check if AirPlay is running (every minute) and if not we would like the script to activate AirPlay again