ios :: AVAudioPlayer :: defaultinit
# Audio player playing audio from a file or from memory
private extern class AVAudioPlayer in "ObjC" `{ AVAudioPlayer *`}
super NSObject
new contents_of(url: NSObject) in "ObjC" `{
NSError *error;
AVAudioPlayer *a = [[AVAudioPlayer alloc] initWithContentsOfURL:(NSURL*)url error:&error];
if (error != nil) {
NSLog(@"Failed to load sound: %@", [error localizedDescription]);
return NULL;
}
return (__bridge AVAudioPlayer*)CFBridgingRetain(a);
`}
fun play in "ObjC" `{ [self play]; `}
fun prepare_to_play in "ObjC" `{ [self prepareToPlay]; `}
fun play_and_repare_async in "ObjC" `{
dispatch_queue_t q = dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0);
dispatch_async(q, ^{
[self play];
[self prepareToPlay];
});
`}
fun release in "ObjC" `{ CFBridgingRelease((__bridge void*)self); `}
end
lib/ios/audio.nit:67,1--95,3