Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehedman committed Nov 7, 2015
0 parents commit 9b043b7
Show file tree
Hide file tree
Showing 8 changed files with 435 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Mike Hedman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# react-native-simple-sound

React Native module for playing, pausing, and stopping sound clips
Derived from Derived from [react-native-sound](https://github.com/zmxv/react-native-sound), which allows multiple sound files to be played at once, but does not offer pause or stop.

## Installation

```javascript
npm install react-native-simple-sound --save
```

In XCode, right click **Libraries**.
Click **Add Files to "[Your project]"**.
Navigate to **node_modules/react-native-simple-sound**.
Add the file **RNSimpleSound.xcodeproj**.

In the project navigator, select your project.
Click the build target.
Click **Build Phases**.
Expand **Link Binary With Libraries**.
Click the plus button and add **libRNSimpleSound.a** under **Workspace**.

Run your project (⌘+R).

## Example

```js
var Sound = require('react-native-simple-sound');
Sound.enable(true); // Enable sound
Sound.prepare('tap.aac'); // Preload the sound file 'tap.aac' in the app bundle
Sound.play(); // Play the sound 'tap.aac'
Sound.pause(); // Pause the sound
Sound.play(); // Resume playing the sound
Sound.stop(); // Stop and reset the sound.
```

## Notes
- Sound.enable(true) must be called before playing any sound.
- Sound.prepare(...) must be called before playing - preloads a sound file and prepares it for playback.
- To change sounds, stop() the current sound and call prepare() with the new sound.
- The module wraps AVAudioPlayer which supports aac, aiff, mp3, wav etc. The full list of supported formats can be found at https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html
- The stop() function resets the sound back to the beginning, this is different from the standard behavior of AVAudioPlayer
- Sound files must be in the bundle (in your app's main folder in Xcode)
262 changes: 262 additions & 0 deletions RNSimpleSound.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
27D4F4331BED747600C15668 /* RNSimpleSound.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 27D4F4321BED747600C15668 /* RNSimpleSound.h */; };
27D4F43B1BED767D00C15668 /* RNSimpleSound.m in Sources */ = {isa = PBXBuildFile; fileRef = 27D4F4341BED747600C15668 /* RNSimpleSound.m */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
27D4F42D1BED747600C15668 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
27D4F4331BED747600C15668 /* RNSimpleSound.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
27D4F42F1BED747600C15668 /* libRNSimpleSound.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNSimpleSound.a; sourceTree = BUILT_PRODUCTS_DIR; };
27D4F4321BED747600C15668 /* RNSimpleSound.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNSimpleSound.h; sourceTree = "<group>"; };
27D4F4341BED747600C15668 /* RNSimpleSound.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNSimpleSound.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
27D4F42C1BED747600C15668 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
27D4F4261BED747600C15668 = {
isa = PBXGroup;
children = (
27D4F4311BED747600C15668 /* RNSimpleSound */,
27D4F4301BED747600C15668 /* Products */,
);
sourceTree = "<group>";
};
27D4F4301BED747600C15668 /* Products */ = {
isa = PBXGroup;
children = (
27D4F42F1BED747600C15668 /* libRNSimpleSound.a */,
);
name = Products;
sourceTree = "<group>";
};
27D4F4311BED747600C15668 /* RNSimpleSound */ = {
isa = PBXGroup;
children = (
27D4F4321BED747600C15668 /* RNSimpleSound.h */,
27D4F4341BED747600C15668 /* RNSimpleSound.m */,
);
path = RNSimpleSound;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
27D4F42E1BED747600C15668 /* RNSimpleSound */ = {
isa = PBXNativeTarget;
buildConfigurationList = 27D4F4381BED747600C15668 /* Build configuration list for PBXNativeTarget "RNSimpleSound" */;
buildPhases = (
27D4F42B1BED747600C15668 /* Sources */,
27D4F42C1BED747600C15668 /* Frameworks */,
27D4F42D1BED747600C15668 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = RNSimpleSound;
productName = RNSimpleSound;
productReference = 27D4F42F1BED747600C15668 /* libRNSimpleSound.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
27D4F4271BED747600C15668 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0710;
ORGANIZATIONNAME = mikehedman;
TargetAttributes = {
27D4F42E1BED747600C15668 = {
CreatedOnToolsVersion = 7.1;
};
};
};
buildConfigurationList = 27D4F42A1BED747600C15668 /* Build configuration list for PBXProject "RNSimpleSound" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 27D4F4261BED747600C15668;
productRefGroup = 27D4F4301BED747600C15668 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
27D4F42E1BED747600C15668 /* RNSimpleSound */,
);
};
/* End PBXProject section */

/* Begin PBXSourcesBuildPhase section */
27D4F42B1BED747600C15668 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
27D4F43B1BED767D00C15668 /* RNSimpleSound.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin XCBuildConfiguration section */
27D4F4361BED747600C15668 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
27D4F4371BED747600C15668 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
27D4F4391BED747600C15668 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"HEADER_SEARCH_PATHS[arch=*]" = (
"$(SRCROOT)/../react-native/React/**",
"$(SRCROOT)/../../React/**",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Debug;
};
27D4F43A1BED747600C15668 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"HEADER_SEARCH_PATHS[arch=*]" = (
"$(SRCROOT)/../react-native/React/**",
"$(SRCROOT)/../../React/**",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
27D4F42A1BED747600C15668 /* Build configuration list for PBXProject "RNSimpleSound" */ = {
isa = XCConfigurationList;
buildConfigurations = (
27D4F4361BED747600C15668 /* Debug */,
27D4F4371BED747600C15668 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
27D4F4381BED747600C15668 /* Build configuration list for PBXNativeTarget "RNSimpleSound" */ = {
isa = XCConfigurationList;
buildConfigurations = (
27D4F4391BED747600C15668 /* Debug */,
27D4F43A1BED747600C15668 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 27D4F4271BED747600C15668 /* Project object */;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions RNSimpleSound/RNSimpleSound.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// RNSimpleSound.h
// RNSimpleSound
//
// Copyright © 2015 mikehedman. All rights reserved.
//

#import "RCTBridgeModule.h"

@interface RNSimpleSound : NSObject <RCTBridgeModule>

@end

Loading

0 comments on commit 9b043b7

Please sign in to comment.