Bug 294056 User-specified sound fails to play after file download completes

r=biesi sr=neil
This commit is contained in:
cst%andrew.cmu.edu 2005-10-23 18:21:36 +00:00
parent 0f7e4ceabf
commit b30dc8ce33
2 changed files with 9 additions and 5 deletions

View File

@ -60,7 +60,6 @@
#include "nsIPromptService.h"
#include "nsIObserverService.h"
#include "nsIProfileChangeStatus.h"
#include "nsISound.h"
#include "nsIPrefService.h"
#include "nsIFileURL.h"
#ifndef MOZ_THUNDERBIRD
@ -1233,16 +1232,18 @@ nsDownload::OnStateChange(nsIWebProgress* aWebProgress,
}
if (!soundStr.IsEmpty()) {
nsCOMPtr<nsISound> snd = do_CreateInstance("@mozilla.org/sound;1");
if (snd) {
if (!mDownloadManager->mSoundInterface) {
mDownloadManager->mSoundInterface = do_CreateInstance("@mozilla.org/sound;1");
}
if (mDownloadManager->mSoundInterface) {
nsCOMPtr<nsIURI> soundURI;
NS_NewURI(getter_AddRefs(soundURI), soundStr);
nsCOMPtr<nsIURL> soundURL(do_QueryInterface(soundURI));
if (soundURL)
snd->Play(soundURL);
mDownloadManager->mSoundInterface->Play(soundURL);
else
snd->Beep();
mDownloadManager->mSoundInterface->Beep();
}
}
if (showAlert)

View File

@ -58,6 +58,7 @@
#include "nsIStringBundle.h"
#include "nsIProgressDialog.h"
#include "nsIMIMEInfo.h"
#include "nsISound.h"
enum DownloadState { NOTSTARTED = -1, DOWNLOADING, FINISHED, FAILED, CANCELED };
@ -89,6 +90,8 @@ protected:
nsresult DownloadEnded(const nsACString& aTargetPath, const PRUnichar* aMessage);
PRBool MustUpdateUI() { if (mDocument) return PR_TRUE; return PR_FALSE; }
nsCOMPtr<nsISound> mSoundInterface;
private:
nsCOMPtr<nsIRDFDataSource> mDataSource;
nsCOMPtr<nsIDOMDocument> mDocument;