Electron.js : Sound file does not execute on notification alert after packaging

13 Views Asked by At

I am making a electron js application i want to alert a sound when notification shows up this works up perfectly when i am in development mode but after i packaged this app the notification alert shows but sound does not execute. My code is writter in module that is attached with main.js file. I have also tried various solutions on the internet but sill the sound file doesn't execute.

I tried to change paths of sound file in different ways but sound still doesn't execute after packaging app. I want to know if there is some different kind of mistake i am doing.

const notifier = require('node-notifier');
const player = require('play-sound')(opts = {});
const path = require('path')

const soundPath = path.join(__dirname, 'alert.wav');

function executeNotification(timeLimit){

  console.log(soundPath)

    let minutes = Math.floor(timeLimit / 60)
  
    notifier.notify({

      title: 'Runing this app',
        message: `runs`,
    
      }, (err, response) => {
        if (err) {
          console.error('Notification error:', err);
        } else {
          console.log('Notification response:', response);
          player.play(soundPath, (playErr) => {
            if (playErr) console.error('Sound playback error:', playErr);
          });
    
        }
      });

  }
  module.exports = executeNotification
  
```
0

There are 0 best solutions below