name, ext = filename.split(".") path = Cocoa::NSBundle._mainBundle. _pathForResource name, :ofType, ext url = Cocoa::NSURL._fileURLWithPath path @avap = Cocoa::AVAudioPlayer._alloc. _initWithContentsOfURL url, :error, nil end def play; @avap._play; end end AudioPlayer.new("bgm00.wav").play