首页 > 移动平台 > 详细

iOS学习笔记31-音频

时间:2016-02-29 21:28:20      阅读:229      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!