Skip to content

Commit 3bff249

Browse files
committed
Merge remote-tracking branch 'origin/1.0.1'
2 parents 0464f55 + f0b8c4c commit 3bff249

File tree

4 files changed

+71
-2
lines changed

4 files changed

+71
-2
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Drop in the Spring folder to your Xcode project.
55

66
Or via CocoaPods pre-release:
7-
`pod 'Spring', '~> 1.0.0'`
7+
`pod 'Spring', '~> 1.0.1'`
88

99
## Usage with Storyboard
1010
In Identity Inspector, connect the UIView to SpringView Class and set the animation properties in Attribute Inspector.
@@ -94,6 +94,9 @@ Animations won't autostart when view is reached via performSegueWithIdentifier.
9494
- Tutorials available on [Design+Code](https://designcode.io/swiftapp).
9595
- [Integrate Spring to existing Objective-C projects](https://medium.com/ios-apprentice/using-swift-in-objective-c-projects-f7e7a09f8be)
9696

97+
## ChangeLog
98+
- At [ChangeLog](https://github.com/MengTo/Spring/wiki/CHANGELOG) wiki page
99+
97100
## License
98101

99102
Spring is released under the MIT license. See LICENSE for details.

Spring.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Spring'
3-
s.version = '1.0.0'
3+
s.version = '1.0.1'
44
s.license = 'MIT'
55
s.summary = 'A library to simplify iOS animations in Swift.'
66
s.homepage = 'https://github.com/MengTo/Spring'

Spring/SoundPlayer.swift

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// The MIT License (MIT)
2+
//
3+
// Copyright (c) 2015 James Tang ([email protected])
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in all
13+
// copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
// SOFTWARE.
22+
23+
import UIKit
24+
import AudioToolbox
25+
26+
public class SoundPlayer: NSObject {
27+
28+
@IBInspectable var filename : String?
29+
@IBInspectable var enabled : Bool = true
30+
31+
private struct Internal {
32+
static var cache = [NSURL:SystemSoundID]()
33+
}
34+
35+
public func playSound(soundFile:String) {
36+
37+
if !enabled {
38+
return
39+
}
40+
41+
if let url = NSBundle.mainBundle().URLForResource(soundFile, withExtension: nil) {
42+
43+
var soundID : SystemSoundID = Internal.cache[url] ?? 0
44+
45+
if soundID == 0 {
46+
AudioServicesCreateSystemSoundID(url, &soundID)
47+
Internal.cache[url] = soundID
48+
}
49+
50+
AudioServicesPlaySystemSound(soundID)
51+
52+
} else {
53+
println("Could not find sound file name `\(soundFile)`")
54+
}
55+
}
56+
57+
@IBAction public func play(sender: AnyObject?) {
58+
if let filename = filename {
59+
self.playSound(filename)
60+
}
61+
}
62+
}

SpringApp.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
1A4FDA6A1A6E44A70099D309 /* TransitionZoom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961888E41A66BF9000295A64 /* TransitionZoom.swift */; };
3737
1A4FDA6B1A6E44A70099D309 /* UnwindSegue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 961888E51A66BF9000295A64 /* UnwindSegue.swift */; };
3838
1A585F401A7B9530007EEB7D /* KeyboardLayoutConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A585F3F1A7B9530007EEB7D /* KeyboardLayoutConstraint.swift */; };
39+
1A9F866D1A83C5640098BE6C /* SoundPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A9F866C1A83C5640098BE6C /* SoundPlayer.swift */; };
3940
1AB764641A6E4F070076CD78 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 964117471A5BE90A000E3A5A /* Images.xcassets */; };
4041
964117411A5BE90A000E3A5A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 964117401A5BE90A000E3A5A /* AppDelegate.swift */; };
4142
964117461A5BE90A000E3A5A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 964117441A5BE90A000E3A5A /* Main.storyboard */; };
@@ -102,6 +103,7 @@
102103
1A4FDA451A6E44780099D309 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
103104
1A4FDA461A6E44780099D309 /* SpringTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpringTests.swift; sourceTree = "<group>"; };
104105
1A585F3F1A7B9530007EEB7D /* KeyboardLayoutConstraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardLayoutConstraint.swift; sourceTree = "<group>"; };
106+
1A9F866C1A83C5640098BE6C /* SoundPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SoundPlayer.swift; sourceTree = "<group>"; };
105107
1AD08AC61A676D5800160D45 /* Spring.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Spring.swift; sourceTree = "<group>"; };
106108
1AF3F11A1A6776760090E8F9 /* SpringImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpringImageView.swift; sourceTree = "<group>"; };
107109
1AF3F11B1A6776760090E8F9 /* SpringLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpringLabel.swift; sourceTree = "<group>"; };
@@ -221,6 +223,7 @@
221223
961888DB1A66BF9000295A64 /* ImageLoader.swift */,
222224
1A585F3F1A7B9530007EEB7D /* KeyboardLayoutConstraint.swift */,
223225
961888DF1A66BF9000295A64 /* Misc.swift */,
226+
1A9F866C1A83C5640098BE6C /* SoundPlayer.swift */,
224227
1AD08AC61A676D5800160D45 /* Spring.swift */,
225228
961888E01A66BF9000295A64 /* SpringAnimation.swift */,
226229
961888E11A66BF9000295A64 /* SpringButton.swift */,
@@ -486,6 +489,7 @@
486489
1A4FDA5A1A6E44A70099D309 /* DesignableTextField.swift in Sources */,
487490
1A4FDA691A6E44A70099D309 /* TransitionManager.swift in Sources */,
488491
1A4FDA5E1A6E44A70099D309 /* ImageLoader.swift in Sources */,
492+
1A9F866D1A83C5640098BE6C /* SoundPlayer.swift in Sources */,
489493
1A4FDA551A6E44A70099D309 /* BlurView.swift in Sources */,
490494
1A4FDA5D1A6E44A70099D309 /* DesignableTabBarController.swift in Sources */,
491495
1A4FDA591A6E44A70099D309 /* DesignableLabel.swift in Sources */,

0 commit comments

Comments
 (0)