您的位置:首页 > 移动开发 > IOS开发

ios最简单的播放音频程序

2016-05-12 21:54 567 查看
//
//  ViewController.m
//  PlayAudio
//
//  Created by hq on 16/5/12.
//  Copyright © 2016年 hanqing. All rights reserved.
//

#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

SystemSoundID sysId=0;

//我们音频文件的路径
NSURL *url=[[NSBundle mainBundle] URLForResource:@"aaa.wav" withExtension:nil];

CFURLRef urlRef=(__bridge CFURLRef)url;

AudioServicesCreateSystemSoundID(urlRef, &sysId);

//声音+震动
AudioServicesPlayAlertSound(sysId);

//声音  AudioServicesPlaySystemSound(sysId);

}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];

}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: