Skip to content

Fix alert audio not playing: resolve sounds dir from plugin root - #278

Merged
bmfmancini merged 1 commit into
developfrom
fix/monitor-sound-path
Oct 16, 2026
Merged

bmfmancini merged 1 commit into
developfrom
fix/monitor-sound-path

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Description

getMonitorSound() in includes/controller.php resolved the sound file with __DIR__ . '/sounds/'. Since the controller moved into includes/, that points at includes/sounds/, which doesn't exist, so the configured sound was never found. isMonitorAudible() then returned false and the <audio id='audio'> element was never rendered, so muteUnmuteAudio() had nothing to play.

The path now uses dirname(__DIR__) . '/sounds/', which points at the plugin's real sounds/ directory. A regression test and a CHANGELOG entry are included.

Related Issue

Audio no longer plays when a device is down or an alert is triggered.

Motivation and Context

This is a code defect from the restructure, not a browser restriction. Browser autoplay policies can still block playback on a freshly opened tab until the user interacts with the page, but that only matters once the audio element is rendered again.

How Has This Been Tested?

  • php -l includes/controller.php passes.
  • Confirmed dirname(__DIR__) . '/sounds/Siren.mp3' resolves to an existing file from includes/.
  • Added tests/Integration/MonitorSoundPathTest.php (not run locally: no Pest in this checkout).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

getMonitorSound() used __DIR__ . '/sounds/' after the controller moved to includes/, so the sound file was never found and the audio element was never printed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 18:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The localized path correction addresses the reported defect with no blocking issues identified.

0 open findings

What changed in this PR

Restores alert audio by resolving sound files from the plugin root rather than the controller’s includes/ directory.

Changes:

  • Corrects the sound-file lookup path.
  • Adds a regression test and changelog entry.
File Description
tests/​Integration/​MonitorSoundPathTest.php Checks the path expression and directory layout.
includes/​controller.php Resolves sounds from the plugin root.
CHANGELOG.md Documents the alert-audio fix.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bmfmancini
bmfmancini merged commit bef1ad8 into develop Oct 16, 2026
6 checks passed
@bmfmancini
bmfmancini deleted the fix/monitor-sound-path branch October 16, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants