#UISound#
Inherits From: NSObject
Declared In: UISound.h
##Overview##
The UISound
class provides a simple interface for loading and playing audio files. This class supports the same audio encodings and file formats that are supported by Audio Toolbox.
To use this class, initialize a new instance with the desired file name. Play your audio data either as an alert or simply sound. Playback occurs synchronously, with vibration where applicable for alerts, and asynchronously otherwise, so that your application can continue doing work.
You should retrain UISound
objects before initiating playback or make sure you have a strong reference to them in a garbage-collected environment. Upon deallocation, a sound object stops playback of the sound so that it can free up the corresponding audio resources. If you want to deallocate a sound object immediately after playback, assign a delegate and use the sound:didFinishPlaying:
method to deallocate it.
##Tasks##
###Configuring Sounds### name (property) delegate (property)
###Creating Sounds### - initWithName: - initWithContentsOfURL: + soundNamed: + soundWithContentsOfURL:
###Getting Sound Information#### + soundUnfilteredTypes
###Playing Sounds### - play - playWithCompletion: - alert - alertWithCompletion:
##Properties##
name
The name of the audio file to be played.
(copy) NSString *name
delegate
The sound's delegate.
(retain) id delegate
##Class Methods##
soundNamed:
Returns the
UISound
instance associated with the given name.
+ (UISound *)soundNamed:(NSString *)soundName
Parameters:
soundName
The name that identifies sound data.
Return Value:
UISound
instance initialized with the sound data identified bysoundName
.
soundUnfilteredTypes
Provides the file types the
UISound
class understands.
+ (NSArray *)soundUnfilteredTypes
Return Value:
Array of UTIs identifying the file types the
UISound
class understands.
soundWithContentsOfURL:
Returns the
UISound
instance associated with the given URL.
+ (UISound *)soundWithContentsOfURL:(NSURL *)url
Parameters:
url
URL that identifies sound data.
Return Value:
UISound
instance initialized with the sound data identified byurl
.
##Instance Methods##
alert:
Initiates audio playback, with vibration where applicable.
- (void)alert
alertWithCompletion:
Initiates audio playback, with vibration where applicable. Runs the provided completion block when playback is completed.
- (void)alertWithCompletion:(void (^)(BOOL finished))completion
initWithName:
Initializes the receiver with the audio data associated with the given name.
+ (id)initWithName:(NSString *)soundName
Parameters:
soundName
The name that identifies sound data.
Return Value:
UISound
instance initialized with the sound data identified bysoundName
.
initWithContentsOfURL:
Initializes the receiver with the audio data associated with the given URL.
+ (id)initWithContentsOfURL:(NSURL *)url
Parameters:
url
URL that identifies sound data.
Return Value:
UISound
instance initialized with the sound data identified byurl
.
play:
Initiates audio playback.
- (void)play
playWithCompletion:
Initiates audio playback and execute the provided completion block when playback is completed.
- (void)playWithCompletion:(void (^)(BOOL finished))completion
#UISoundDelegate Protocol Reference#
Declared In: UISound.h
##Overview##
The UISoundDelegate
protocol defines the optional methods implemented by delegates of UISound
objects.
##Tasks##
###Playing Sounds### - sound:didFinishPlaying:
##Instance Methods##
sound:didFinishPlaying:
This delegate method is called when a
UISound
instance has completed playback of its sound data.
- (void)sound:(UISound *)sound didFinishPlaying:(BOOL)finishedPlaying
Parameters:
sound
The
UISound
that has completed playback of its sound data.
finishedPlaying
YES
when playback was successful;NO
otherwise.
#Attribution#
Original Author: Patrick Perini https://github.com/pcperini/UISound
#License#
License Agreement for Source Code provided by Ben Liong
This software is supplied to you by Ben Liong in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this software.
In consideration of your agreement to abide by the following terms, and subject to these terms, Ben Liong grants you a personal, non-exclusive license, to use, reproduce, modify and redistribute the software, with or without modifications, in source and/or binary forms; provided that if you redistribute the software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the software, and that in all cases attribution of Ben Liong as the original author of the source code shall be included in all such resulting software products or distributions. Neither the name, trademarks, service marks or logos of Ben Liong may be used to endorse or promote products derived from the software without specific prior written permission from Ben Liong. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Ben Liong herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the software may be incorporated.
The software is provided by Ben Liong on an "AS IS" basis. Ben Liong MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL Ben Liong BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF Ben Liong HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.