cocoa nsSound impl. bug 357307. r=vlad

This commit is contained in:
pavlov%pavlov.net 2006-10-19 21:05:54 +00:00
parent 8312ec86cd
commit 50242832e6
2 changed files with 25 additions and 6 deletions

View File

@ -21,6 +21,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <stuart@mozilla.com>
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
@ -48,12 +49,12 @@ class nsSound : public nsISound,
{
public:
nsSound();
virtual ~nsSound();
nsSound();
virtual ~nsSound();
NS_DECL_ISUPPORTS
NS_DECL_NSISOUND
NS_DECL_NSISTREAMLOADEROBSERVER
NS_DECL_ISUPPORTS
NS_DECL_NSISOUND
NS_DECL_NSISTREAMLOADEROBSERVER
};
#endif

View File

@ -21,6 +21,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <stuart@mozilla.com>
* Vladimir Vukicevic <vladimir@pobox.com>
*
* Alternatively, the contents of this file may be used under the terms of
@ -39,6 +40,13 @@
#include "nsSound.h"
#include <Foundation/NSData.h>
#include <AppKit/NSSound.h>
#include "nsNetUtil.h"
#include "nsCOMPtr.h"
#include "nsIURL.h"
NS_IMPL_ISUPPORTS1(nsSound, nsISound)
nsSound::nsSound()
@ -62,13 +70,23 @@ nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
PRUint32 dataLen,
const PRUint8 *data)
{
NSData *value = [NSData dataWithBytes:data length:dataLen];
NSSound *sound = [[NSSound alloc] initWithData:value];
[sound play];
[sound autorelease];
return NS_OK;
}
NS_IMETHODIMP
nsSound::Play(nsIURL *aURL)
{
return NS_OK;
nsCOMPtr<nsIURI> uri(do_QueryInterface(aURL));
nsCOMPtr<nsIStreamLoader> loader;
return NS_NewStreamLoader(getter_AddRefs(loader), uri, this);
}
NS_IMETHODIMP