Skip to content

Commit

Permalink
Merge pull request #15 from fewieden/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
fewieden authored May 27, 2018
2 parents b5158cb + bdca3a4 commit c5a4cda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions MMM-AlarmClock.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,16 @@ Module.register('MMM-AlarmClock', {
wrapper.appendChild(text);
} else if (this.alarmFired) {
const sound = document.createElement('audio');
sound.setAttribute('id', 'MMM-AlarmClock-Player');
if (this.config.sound.match(/^https?:\/\//)) {
sound.src = this.config.sound;
} else {
sound.src = this.file(`sounds/${this.config.sound}`);
let srcSound = this.config.sound;
if (this.next.sound) {
srcSound = this.next.sound;
}
if (!srcSound.match(/^https?:\/\//)) {
srcSound = this.file(`sounds/${srcSound}`);
}
sound.src = srcSound;
sound.volume = this.config.volume;
sound.setAttribute('id', 'MMM-AlarmClock-Player');
sound.volume = this.config.fade ? 0 : this.config.volume;
sound.setAttribute('autoplay', true);
sound.setAttribute('loop', true);
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Alarm Clock Module for MagicMirror<sup>2</sup>
position: 'top_right',
config: {
alarms: [
{time: "18:30", days: [2,4], title: "Soccer", message: "Get ready for soccer training!"},
{time: "18:30", days: [2,4], title: "Soccer", message: "Get ready for soccer training!", sound: "alarm.mp3"},
...
],
...
Expand All @@ -33,7 +33,7 @@ Alarm Clock Module for MagicMirror<sup>2</sup>
| **Option** | **Default** | **Description** |
| --- | --- | --- |
| `alarm` | `REQUIRED` | An Array with all your alarms as objects. Those objects need to have the properties -> time: 24h format, days: Array of all days the alarm should be fired (0 = Sunday, 6 = Saturday), title and message. |
| `alarms` | `REQUIRED` | An Array with all your alarms as objects. Those objects need to have the properties -> time: 24h format, days: Array of all days the alarm should be fired (0 = Sunday, 6 = Saturday), title, message, and sound. If sound is not defined, alarm will be fired with module defined/default alarm sound. |
| `sound` | `'alarm.mp3'` | Name and extension of your alarm sound. File needs to be placed in `~/MagicMirror/modules/MMM-AlarmClock/sounds`. Standard files are `alarm.mp3` and `blackforest.mp3`. Alternatively specify a web stream `http` or `https`. |
| `volume` | `1.0` | The volume of the alarm sound in a range from `0.0` to `1.0` |
| `touch` | `false` | If you are using a touch screen device you need to press a button to disable an alarm.. |
Expand Down

0 comments on commit c5a4cda

Please sign in to comment.