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

iOS学习笔记31-音频

时间:2016-02-29 21:30:53      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:

#import <AVFoundation/AVFoundation.h>

 

@interface ViewController ()

@property(nonatomic,strong)AVAudioPlayer *player;

@end

 

@implementation ViewController

 

-(AVAudioPlayer *)player

{

    if (!_player) {

        NSURL *url = [[NSBundle mainBundle]URLForResource:@"爱火花.mp3" withExtension:nil];

        

        _player = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:nil];

        [self.player prepareToPlay];

        

    }

    return _player;

}

 

 

- (IBAction)play {

    [self.player play];

    

}

- (IBAction)pause:(id)sender {

    [self.player pause];

}

- (IBAction)stop {

    [self.player stop];

    

}

 

iOS学习笔记31-音频

标签:

原文地址:http://www.cnblogs.com/adodo/p/5228777.html

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