dariowouters / ts-fmod-plugin

A telemetry plugin for ATS/ETS2 to use FMOD sound mods (to a limited extent) for example in TruckersMP
MIT License
45 stars 12 forks source link

Mute audio when not in focus #19

Closed Baldywaldy09 closed 7 months ago

Baldywaldy09 commented 7 months ago

Description:

Saw in the limitations/issues that it didn't mute the plugins audio when you alt tabbed [aka lost window focus] so I made this to fix that issue

How it works:

  1. Checks the current window title
  2. if is_focused is true it then checks if the window title doesn't equal one of the allowed_windows if it doesn't then it will set the master volume to 0 and set is_focused to false if the window title does equal one of the allowed_windows then it does nothing
  3. if is_focused is false it then checks if the window title does equal one of the allows_windows if it does then it will set the master volume to the value in sound_levels.txt and set is_focused to true if the window title doesn't equal one of the allowed_windows then it does nothing

Example Video:

Example Video