中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

iOS 簡(jiǎn)單的音頻操作代碼

2018-07-20    來(lái)源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用
//
//  ViewController.m
//  嘗試音效
//
//  Created by chen on 15/3/18.
//  Copyright (c) 2015年 lanrw. All rights reserved.
//
 
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
 
@interface ViewController ()
@property (nonatomic,strong)AVAudioPlayer *av;
@property (nonatomic,strong)AVAudioRecorder *rd;
@end
 
@implementation ViewController
/**
 *  播放音效
 */
- (IBAction)button1:(id)sender {
    NSURL *url = [[NSBundle mainBundle]URLForResource:@"A-Game Glitch Synth.caf" withExtension:nil];
    SystemSoundID soundId;
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)(url), &soundId);
    AudioServicesPlayAlertSound(soundId);
}
 
/**
 *  播放音樂(lè)
 */
- (IBAction)button2:(id)sender {
    NSURL *url = [[NSBundle mainBundle]URLForResource:@"當(dāng)你老了.mp3" withExtension:nil];
    _av = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:nil];
    [_av prepareToPlay];
    [_av play];
}
 
/**
 *  按下錄音
 */
- (IBAction)button3:(id)sender {
    NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
    path = [path stringByAppendingPathComponent:@"test.wav"];
    NSURL *url = [NSURL fileURLWithPath:path];
    _rd = [[AVAudioRecorder alloc]initWithURL:url settings:nil error:nil];
    [_rd prepareToRecord];
    [_rd record];
}
/**
 *  彈起完成錄音
 */
- (IBAction)button4:(id)sender {
    [_rd stop];
}
 
 
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
@end

標(biāo)簽: isp

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:Android圖片處理工具類(lèi)(圓角,壓縮)

下一篇:php獲得用戶的真實(shí)IP