Change an entity status when tab changes

Hello,

Is it possible to change an entity when a different tab is chosen.

I have a camera image to each tab with a button to start ffmpeg audio. However, if I then choose a different tab the audio continues. What I want is to stop the ffmpeg stream when the new tab is pressed.

Thanks in advance

Try to automating it with browser_mod