mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 13:25:37 +00:00
Bug 16498 Finished Downloading sounds
patch by cst@andrew.cmu.edu r=varga sr=bz
This commit is contained in:
parent
28372ff680
commit
43ee8e9f0b
@ -43,6 +43,8 @@ REQUIRES = xpcom \
|
|||||||
appshell \
|
appshell \
|
||||||
dom \
|
dom \
|
||||||
profile \
|
profile \
|
||||||
|
widget \
|
||||||
|
pref \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
CPPSRCS = \
|
CPPSRCS = \
|
||||||
nsDownloadManager.cpp \
|
nsDownloadManager.cpp \
|
||||||
|
@ -59,6 +59,9 @@
|
|||||||
#include "nsIPromptService.h"
|
#include "nsIPromptService.h"
|
||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
#include "nsIProfileChangeStatus.h"
|
#include "nsIProfileChangeStatus.h"
|
||||||
|
#include "nsISound.h"
|
||||||
|
#include "nsIPrefService.h"
|
||||||
|
#include "nsIURL.h"
|
||||||
|
|
||||||
/* Outstanding issues/todo:
|
/* Outstanding issues/todo:
|
||||||
* 1. Implement pause/resume.
|
* 1. Implement pause/resume.
|
||||||
@ -1216,6 +1219,33 @@ nsDownload::OnStateChange(nsIWebProgress* aWebProgress,
|
|||||||
mCurrBytes = mMaxBytes;
|
mCurrBytes = mMaxBytes;
|
||||||
mPercentComplete = 100;
|
mPercentComplete = 100;
|
||||||
|
|
||||||
|
//Play a sound when the download finishes
|
||||||
|
nsXPIDLCString soundStr;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1");
|
||||||
|
|
||||||
|
if (prefs) {
|
||||||
|
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||||
|
prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
||||||
|
if (prefBranch)
|
||||||
|
prefBranch->GetCharPref("browser.download.finished_sound_url", getter_Copies(soundStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
//only continue if it isn't blank
|
||||||
|
if (!soundStr.IsEmpty()) {
|
||||||
|
nsCOMPtr<nsISound> snd = do_GetService("@mozilla.org/sound;1");
|
||||||
|
if (snd) { //hopefully we got it
|
||||||
|
nsCOMPtr<nsIURI> soundURI;
|
||||||
|
|
||||||
|
NS_NewURI(getter_AddRefs(soundURI), soundStr);
|
||||||
|
nsCOMPtr<nsIURL> soundURL(do_QueryInterface(soundURI));
|
||||||
|
if (soundURL)
|
||||||
|
snd->Play(soundURL);
|
||||||
|
else
|
||||||
|
snd->Beep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nsAutoString path;
|
nsAutoString path;
|
||||||
rv = mTarget->GetPath(path);
|
rv = mTarget->GetPath(path);
|
||||||
// can't do an early return; have to break reference cycle below
|
// can't do an early return; have to break reference cycle below
|
||||||
|
Loading…
Reference in New Issue
Block a user