c0de0ff / DownloadManager

Download Manger for chrome web browser
117 stars 104 forks source link

Notification sound request #53

Open DiegoFleitas opened 7 years ago

DiegoFleitas commented 7 years ago

It works! I can even drag images from the download popup

But I wish it had a "Notification sound" switch, independient from that "Download Completion Notification" because I want sound to play but nothing to appear on my screen.

Here's some pseudocode from an extension I put together a while ago that does it

Great extension, thanks for doing this

//Reproduce mp3
function playSound() {
        var myAudio = new Audio();
        myAudio.src = chrome.extension.getURL("sound/notification2.mp3");
        var playPromise = myAudio.play();

        // In browsers that don’t yet support this functionality,
        // playPromise won’t be defined.
        if (playPromise !== undefined) {
          playPromise.then(function() {
            // Automatic playback started!
          }).catch(function(error) {
            // Automatic playback failed.
            // Show a UI element to let the user manually start playback.
          });
        }
}

var cd = chrome.downloads;
if(typeof cd !== "undefined"){
    cd.onChanged.addListener(function(delta){
      if (delta.state && delta.state.current === "complete")
          playSound();
    });
}