44//
55// Created by Mark Hamilton on 2/16/16.
66// Copyright © 2016 dryverless. (http://www.dryverless.com)
7- //
7+ //
88// Permission is hereby granted, free of charge, to any person obtaining a copy
99// of this software and associated documentation files (the "Software"), to deal
1010// in the Software without restriction, including without limitation the rights
1111// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1212// copies of the Software, and to permit persons to whom the Software is
1313// furnished to do so, subject to the following conditions:
14- //
14+ //
1515// The above copyright notice and this permission notice shall be included in all
1616// copies or substantial portions of the Software.
17- //
17+ //
1818// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1919// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2020// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2121// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2222// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2323// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2424// SOFTWARE.
25- //
25+ //
2626
2727import UIKit
2828import AVFoundation
2929
30- class SoundEffect {
30+ public class SoundEffect {
3131
3232 private var _name : String ! = " sound "
3333 private var _ofType : String ! = " wav "
@@ -38,21 +38,21 @@ class SoundEffect {
3838 private var _duration : NSTimeInterval ! = nil
3939 private var _numberOfLoops : Int ! = 0
4040
41- var sound : AVAudioPlayer !
41+ public var sound : AVAudioPlayer !
4242
43- var name : String {
43+ public var name : String {
4444 get {
4545 return _name
4646 }
4747 }
4848
49- var ofType : String {
49+ public var ofType : String {
5050 get {
5151 return _ofType
5252 }
5353 }
5454
55- var isEnabled : Bool {
55+ public var isEnabled : Bool {
5656 get {
5757 if let enableBool: Bool = _isEnabled {
5858 return enableBool
@@ -62,13 +62,13 @@ class SoundEffect {
6262 }
6363 }
6464
65- var loop : Bool {
65+ public var loop : Bool {
6666 get {
6767 return _loop
6868 }
6969 }
7070
71- var playing : Bool {
71+ public var playing : Bool {
7272 get {
7373 if let isPlaying: Bool = sound. playing {
7474 return isPlaying
@@ -80,13 +80,13 @@ class SoundEffect {
8080 }
8181 }
8282
83- var volume : Float {
83+ public var volume : Float {
8484 get {
8585 return _volume
8686 }
8787 }
8888
89- var duration : NSTimeInterval {
89+ public var duration : NSTimeInterval {
9090 get {
9191 if let soundDuration: NSTimeInterval = sound. duration {
9292 return soundDuration
@@ -96,20 +96,20 @@ class SoundEffect {
9696 }
9797 }
9898
99- var numberOfLoops : Int {
99+ public var numberOfLoops : Int {
100100 get {
101101 return _numberOfLoops
102102 }
103103 }
104104
105- init ( fileName: String , fileType: String ) {
105+ public init ( fileName: String , fileType: String ) {
106106
107107 self . _name = fileName
108108 self . _ofType = fileType
109109
110110 }
111111
112- init ( fileName: String , fileType: String , enableSound: Bool ? , enableLooping: Bool ? ) {
112+ public init ( fileName: String , fileType: String , enableSound: Bool ? , enableLooping: Bool ? ) {
113113
114114 self . _name = fileName
115115 self . _ofType = fileType
@@ -121,10 +121,10 @@ class SoundEffect {
121121 if let looping = enableLooping {
122122 self . _loop = looping
123123 }
124-
124+
125125 }
126126
127- init ( fileName: String , fileType: String , enableSound: Bool ? , enableLooping: Bool ? , loopTotal: Int ? , defaultVolume: Float ? ) {
127+ public init ( fileName: String , fileType: String , enableSound: Bool ? , enableLooping: Bool ? , loopTotal: Int ? , defaultVolume: Float ? ) {
128128
129129 self . _name = fileName
130130 self . _ofType = fileType
@@ -146,7 +146,7 @@ class SoundEffect {
146146 }
147147 }
148148
149- init ( fileName: String , fileType: String , enableSound: Bool ? , enableLooping: Bool ? , defaultVolume: Float ? ) {
149+ public init ( fileName: String , fileType: String , enableSound: Bool ? , enableLooping: Bool ? , defaultVolume: Float ? ) {
150150
151151 self . _name = fileName
152152 self . _ofType = fileType
@@ -164,11 +164,11 @@ class SoundEffect {
164164 }
165165 }
166166
167- init ( ) {
167+ public init ( ) {
168168 // must have sound.wav file
169169 }
170170
171- func prepareToPlay( ) {
171+ public func prepareToPlay( ) {
172172
173173 let path = NSBundle . mainBundle ( ) . pathForResource ( self . name, ofType: self . ofType)
174174
@@ -198,7 +198,7 @@ class SoundEffect {
198198 }
199199 }
200200
201- func play( ) {
201+ public func play( ) {
202202
203203 if sound. playing {
204204 sound. stop ( )
@@ -209,37 +209,37 @@ class SoundEffect {
209209 }
210210 }
211211
212- func stop( ) {
212+ public func stop( ) {
213213
214214 if sound. playing {
215215 sound. stop ( )
216216 }
217217 }
218218
219- func pause( ) {
219+ public func pause( ) {
220220
221221 if sound. playing {
222222 sound. pause ( )
223223 }
224-
224+
225225 }
226226
227- func enable( ) {
227+ public func enable( ) {
228228
229229 _isEnabled = true
230230 }
231231
232- func disable( ) {
232+ public func disable( ) {
233233
234234 _isEnabled = false
235235 }
236236
237- func toggle( ) {
237+ public func toggle( ) {
238238
239239 _isEnabled = !_isEnabled
240240 }
241241
242- func setVolume( level: Float ) {
242+ public func setVolume( level: Float ) {
243243
244244 if sound. playing {
245245 sound. volume = level
0 commit comments