The sound source object of the music currently playing has been exposed to JS, thus allowing for real-time volume control of music, as well as other properties like looping, position, etc. The function returning the sound source object is Sound.musicSoundSource().
This commit is contained in:
parent
ee11f24710
commit
279bb59056
@ -31,6 +31,7 @@ SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "OOALSound.h"
|
||||
#import "OOSoundSource.h"
|
||||
|
||||
|
||||
@interface OOMusic: OOSound
|
||||
@ -44,5 +45,6 @@ SOFTWARE.
|
||||
- (BOOL) isPlaying;
|
||||
- (void) setMusicGain:(float)newValue;
|
||||
- (float) musicGain;
|
||||
- (OOSoundSource *)musicSoundSource;
|
||||
|
||||
@end
|
||||
|
@ -27,7 +27,6 @@ SOFTWARE.
|
||||
*/
|
||||
|
||||
#import "OOALMusic.h"
|
||||
#import "OOSoundSource.h"
|
||||
|
||||
static OOMusic *sPlayingMusic = nil;
|
||||
static OOSoundSource *sMusicSource = nil;
|
||||
@ -106,6 +105,12 @@ static OOSoundSource *sMusicSource = nil;
|
||||
}
|
||||
|
||||
|
||||
- (OOSoundSource *)musicSoundSource
|
||||
{
|
||||
return sMusicSource;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)isPlaying
|
||||
{
|
||||
return sPlayingMusic == self && [sMusicSource isPlaying];
|
||||
|
@ -26,6 +26,7 @@ MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#import "OOCocoa.h"
|
||||
#import "OOSoundSource.h"
|
||||
|
||||
@class OOMusic;
|
||||
|
||||
@ -77,6 +78,8 @@ typedef enum
|
||||
|
||||
- (void) toggleDockingMusic; // Start docking music if none playing, stop docking music if currently playing docking music.
|
||||
|
||||
- (OOSoundSource *) soundSource;
|
||||
|
||||
- (NSString *) playingMusic;
|
||||
- (BOOL) isPlaying;
|
||||
|
||||
|
@ -224,6 +224,12 @@ enum
|
||||
}
|
||||
|
||||
|
||||
- (OOSoundSource *) soundSource
|
||||
{
|
||||
return [_current musicSoundSource];
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) playingMusic
|
||||
{
|
||||
return [_current name];
|
||||
|
@ -40,6 +40,7 @@ static JSBool SoundGetProperty(JSContext *context, JSObject *this, jsid propID,
|
||||
|
||||
// Static methods
|
||||
static JSBool SoundStaticLoad(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool SoundStaticMusicSoundSource(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool SoundStaticPlayMusic(JSContext *context, uintN argc, jsval *vp);
|
||||
static JSBool SoundStaticStopMusic(JSContext *context, uintN argc, jsval *vp);
|
||||
|
||||
@ -88,6 +89,7 @@ static JSFunctionSpec sSoundStaticMethods[] =
|
||||
{
|
||||
// JS name Function min args
|
||||
{ "load", SoundStaticLoad, 1, },
|
||||
{ "musicSoundSource", SoundStaticMusicSoundSource,0, },
|
||||
{ "playMusic", SoundStaticPlayMusic, 1, },
|
||||
{ "stopMusic", SoundStaticStopMusic, 0, },
|
||||
{ 0 }
|
||||
@ -196,6 +198,18 @@ static JSBool SoundStaticLoad(JSContext *context, uintN argc, jsval *vp)
|
||||
}
|
||||
|
||||
|
||||
static JSBool SoundStaticMusicSoundSource(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
OOJS_NATIVE_ENTER(context)
|
||||
OOSoundSource *musicSource = nil;
|
||||
OOJS_BEGIN_FULL_NATIVE(context)
|
||||
musicSource = [[OOMusicController sharedController] soundSource];
|
||||
OOJS_END_FULL_NATIVE
|
||||
OOJS_RETURN_OBJECT(musicSource);
|
||||
OOJS_NATIVE_EXIT
|
||||
}
|
||||
|
||||
|
||||
// playMusic(name : String [, loop : Boolean] [, gain : float])
|
||||
static JSBool SoundStaticPlayMusic(JSContext *context, uintN argc, jsval *vp)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user