Navigation Menu

Skip to content

Commit

Permalink
Updated to version 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed May 17, 2012
1 parent 750b9ce commit b8191df
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
Expand Up @@ -18,6 +18,7 @@
B2147F25134483F600C8FB9B /* sound2.caf in Resources */ = {isa = PBXBuildFile; fileRef = B2147F1E134483F600C8FB9B /* sound2.caf */; };
B2147F26134483F600C8FB9B /* track1.caf in Resources */ = {isa = PBXBuildFile; fileRef = B2147F1F134483F600C8FB9B /* track1.caf */; };
B2147F27134483F600C8FB9B /* track2.caf in Resources */ = {isa = PBXBuildFile; fileRef = B2147F20134483F600C8FB9B /* track2.caf */; };
B22B85171564FA540001A7C2 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B22B85161564FA540001A7C2 /* AVFoundation.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -40,13 +41,15 @@
B2147F1E134483F600C8FB9B /* sound2.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = sound2.caf; sourceTree = "<group>"; };
B2147F1F134483F600C8FB9B /* track1.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = track1.caf; sourceTree = "<group>"; };
B2147F20134483F600C8FB9B /* track2.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = track2.caf; sourceTree = "<group>"; };
B22B85161564FA540001A7C2 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
B2147EF01344827400C8FB9B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B22B85171564FA540001A7C2 /* AVFoundation.framework in Frameworks */,
B2147EF81344827400C8FB9B /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -86,6 +89,7 @@
B2147EF61344827400C8FB9B /* Frameworks */ = {
isa = PBXGroup;
children = (
B22B85161564FA540001A7C2 /* AVFoundation.framework */,
B2147EF71344827400C8FB9B /* Cocoa.framework */,
B2147EF91344827400C8FB9B /* Other Frameworks */,
);
Expand Down Expand Up @@ -282,6 +286,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "SoundManagerExample/SoundManagerExample-Prefix.pch";
INFOPLIST_FILE = "SoundManagerExample/SoundManagerExample-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -297,6 +302,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "SoundManagerExample/SoundManagerExample-Prefix.pch";
INFOPLIST_FILE = "SoundManagerExample/SoundManagerExample-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
2 changes: 1 addition & 1 deletion LICENCE.md
@@ -1,6 +1,6 @@
SoundManager

Version 1.3, May 15th, 2012
Version 1.3.1, May 17th, 2012

Copyright (C) 2011 Charcoal Design

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -23,7 +23,7 @@ As of version 1.2, SoundManager automatically works with both ARC and non-ARC pr
Installation
--------------

To use the SoundManager class in an app, just drag the class files into your project. For iOS apps you will also need to add the AVFoundation framework.
To use the SoundManager class in an app, just drag the class files into your project. For iOS apps, or Mac OS apps with a deployment target of 10.7 (Lion) or above you will also need to add the AVFoundation framework.


Classes
Expand Down
4 changes: 4 additions & 0 deletions RELEASE NOTES.md
@@ -1,3 +1,7 @@
Version 1.3.1

- For Mac OS projects with a deployment target of Mac OS 10.7 (Lion) or above, SoundManager now uses AVAudioPlayer instead of NSSound

Version 1.3

- Added block-based completion handler callback for Sound class
Expand Down
21 changes: 15 additions & 6 deletions SoundManager/SoundManager.h
@@ -1,7 +1,7 @@
//
// SoundManager.h
//
// Version 1.3
// Version 1.3.1
//
// Created by Nick Lockwood on 29/01/2011.
// Copyright 2010 Charcoal Design
Expand Down Expand Up @@ -67,13 +67,22 @@


#import <Availability.h>
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED)
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#define SMSound AVAudioPlayer
#define SM_USE_AV_AUDIO_PLAYER
#else
#import <Cocoa/Cocoa.h>
#define SMSound NSSound
#if __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_6
#define SM_USE_AV_AUDIO_PLAYER
#endif
#endif


#ifdef SM_USE_AV_AUDIO_PLAYER
#import <AVFoundation/AVFoundation.h>
#define SM_SOUND AVAudioPlayer
#else
#define SM_SOUND NSSound
#endif


Expand All @@ -98,7 +107,7 @@ typedef void (^SoundCompletionHandler)(BOOL didFinish);
NSTimer *timer;
Sound *selfReference;
NSURL *url;
SMSound *sound;
SM_SOUND *sound;
SoundCompletionHandler completionHandler;
}
#endif
Expand Down
19 changes: 11 additions & 8 deletions SoundManager/SoundManager.m
@@ -1,7 +1,7 @@
//
// SoundManager.m
//
// Version 1.3
// Version 1.3.1
//
// Created by Nick Lockwood on 29/01/2011.
// Copyright 2010 Charcoal Design
Expand Down Expand Up @@ -40,7 +40,7 @@
NSString *const SoundDidFinishPlayingNotification = @"SoundDidFinishPlayingNotification";


#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
#ifdef SM_USE_AV_AUDIO_PLAYER
@interface Sound() <AVAudioPlayerDelegate>
#else
@interface Sound() <NSSoundDelegate>
Expand All @@ -52,7 +52,7 @@ @interface Sound() <NSSoundDelegate>
@property (nonatomic, assign) NSTimeInterval fadeStart;
@property (nonatomic, strong) NSTimer *timer;
@property (nonatomic, strong) Sound *selfReference;
@property (nonatomic, strong) SMSound *sound;
@property (nonatomic, strong) SM_SOUND *sound;

- (void)prepareToPlay;

Expand Down Expand Up @@ -118,7 +118,7 @@ - (Sound *)initWithContentsOfURL:(NSURL *)_url;
url = AH_RETAIN(_url);
baseVolume = 1.0f;

#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
#ifdef SM_USE_AV_AUDIO_PLAYER
sound = [[AVAudioPlayer alloc] initWithContentsOfURL:_url error:NULL];
#else
sound = [[NSSound alloc] initWithContentsOfURL:_url byReference:YES];
Expand All @@ -135,9 +135,12 @@ - (void)prepareToPlay
if (prepared) return;
prepared = YES;

#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
#ifdef SM_USE_AV_AUDIO_PLAYER

#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
[AVAudioSession sharedInstance];
#endif

[sound prepareToPlay];

#else
Expand Down Expand Up @@ -196,7 +199,7 @@ - (void)setVolume:(float)volume
- (BOOL)isLooping
{

#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
#ifdef SM_USE_AV_AUDIO_PLAYER
return [sound numberOfLoops] == -1;
#else
return [sound loops];
Expand All @@ -207,7 +210,7 @@ - (BOOL)isLooping
- (void)setLooping:(BOOL)looping
{

#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
#ifdef SM_USE_AV_AUDIO_PLAYER
[sound setNumberOfLoops:looping? -1: 0];
#else
[sound setLoops:looping];
Expand Down Expand Up @@ -252,7 +255,7 @@ - (void)stop
}
}

#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
#ifdef SM_USE_AV_AUDIO_PLAYER
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)finishedPlaying
#else
- (void)sound:(NSSound *)_sound didFinishPlaying:(BOOL)finishedPlaying
Expand Down

0 comments on commit b8191df

Please sign in to comment.