码迷,mamicode.com
首页 > 移动开发 > 详细

IOS 播放音频

时间:2014-06-27 19:21:27      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:ext   com   os   set   cti   for   

1,播放短音频

#import <AudioToolbox/AudioToolbox.h>
#import "GLYViewController.h"
static void completionCallback(SystemSoundID mySSID)
{
AudioServicesPlaySystemSound(mySSID);
}
@interface GLYViewController ()

@end

@implementation GLYViewController
SystemSoundID crash;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL* crashUrl = [[NSBundle mainBundle] URLForResource:@"crash"
withExtension:@"wav"];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)crashUrl, &crash);

AudioServicesAddSystemSoundCompletion(crash, NULL, NULL, (void *)completionCallback, NULL);
}
- (IBAction)play:(id)sender {
AudioServicesPlayAlertSound(crash);
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

IOS 播放音频,布布扣,bubuko.com

IOS 播放音频

标签:ext   com   os   set   cti   for   

原文地址:http://www.cnblogs.com/guanliyang/p/3809682.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!