Load a Sound File - ParkinT/RubyMotion_Life GitHub Wiki

How To

Load a Sound File

# load sound
path = NSBundle.mainBundle.pathForResource("soundeffect", ofType:"wav")
url = NSURL.fileURLWithPath(path)
error_ptr = Pointer.new(:id)
@@staticSound = AVAudioPlayer.alloc.initWithContentsOfURL(url, error:error_ptr)
@@staticSound.prepareToPlay