It does not seem to be related to lock screen necessarily, because if I lock it manually, it stays playing (not always...) and then after those magic 2-3 minutes it stops anyway.
The Workaround which works for me well is to setup 2 things on iPhone:
- Auto-Lock setup to Never
- Settings > General > Auto-lock > Never
- Airplay setup to screen mirroring
- tick AppleTV check box
- switch on Mirroring