ios - AVAudioPlayer Object Sound Not Playing - Swift -


I created an object class of the audio player below to run noise:

  class music audio : NSobies, AviPro Player Delaygate {var bass audio: aviideo player! = AVAudioPlayer () Override init () {super.init () go bassAudioPath = NSBundle.mainBundle () pathForResource ("RAW", ofType: "MP3") Go fileURL = NSURL (fileURLWithPath: bassAudioPath) bassAudio = AVAudioPlayer (contentsOfURL: fileURL, error: zero) bassAudio.currentTime = 0 bassAudio.volume = 1.0 bassAudio.delegate = self} function adjustAudioLayerState (volumeOn: bool, layer: AudioLayerState) {if play layer == AudioLayerState.Bass {self.bassAudio.prepareToPlay () noise, I call through this class:  
  @IBAction func testSound () {var sound: MusicAudio = the MusicAudio () sound.adjustAudioLayerState (true, layer: AudioLayerState.Bass)} is   

However, I do not get any audio played back, either with my implementation someone Msya can see?

Edit: after the rdelmar reply

  var bass audio: aviideo player! = AVAudioPlayer () class MusicAudio: NSObject, AVAudioPlayerDelegate {override the init () {super.init () to bassAudioPath = NSBundle.mainBundle () pathForResource ( "RAW", ofType: "MP3"). Go fileURL = NSURL (fileURLWithPath: bassAudioPath!) BassAudio = AVAudioPlayer (contentsOfURL: fileURL, error: zero) bassAudio.currentTime = 0 bassAudio.volume = 1.0 bassAudio.delegate = self} function adjustAudioLayerState (volumeOn: bool, layer: AudioLayerState) { If layer == AudioLayerState.Bass {Self.bassAudio.prepareToPlay () self.bassAudio.play ()}}}    

You do not get any sound because your music audio group is being distributed. If you wish, sound, is an asset, not a need to create local variables

  class ViewController: UIViewController {var sound = MusicAudio () @IBAction function testSound () {self.sound.adjustAudioLayerState (True, Layer: Audio Launcher .bas)}}    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -