iOS 设置音频倍速播放
2013-11-18 17:23
309 查看
ViewController.h
ViewController.m
代码下载例子: http://pan.baidu.com/s/1raY8J
// // ViewController.h // iOSAudio // // Created by 杜甲 on 13-11-18. // Copyright (c) 2013年 杜甲. All rights reserved. // #import <UIKit/UIKit.h> #import <***Foundation/***Foundation.h> @interface ViewController : UIViewController<***AudioPlayerDelegate> @property (strong , nonatomic) ***AudioPlayer* player; @end
ViewController.m
// // ViewController.m // iOSAudio // // Created by 杜甲 on 13-11-18. // Copyright (c) 2013年 杜甲. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self playBackgroundSoundEffect]; } -(void)playBackgroundSoundEffect { NSString* soundFilePath = [[NSBundle mainBundle] pathForResource:@"nan" ofType:@"mp3"]; NSLog(@"%@",soundFilePath); // NSString* fileStr = [soundFilePath stringByAddingPercentEscapesUsingEncoding:<#(NSStringEncoding)#>]; NSURL* fileUrl = [NSURL fileURLWithPath:soundFilePath ]; NSLog(@"%@",fileUrl); ***AudioPlayer* newPlayer = [[***AudioPlayer alloc] initWithContentsOfURL:fileUrl error:nil]; self.player = newPlayer; [self.player prepareToPlay]; self.player.delegate =self; self.player.volume = 1; //newPlayer.numberOfLoops = -1; //开启倍速 self.player.enableRate = true; //设置倍速参数 self.player.rate = 2; [self.player play]; [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(getTime) userInfo:nil repeats:YES]; } -(void)getTime { NSLog(@"%f",self.player.duration); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
代码下载例子: http://pan.baidu.com/s/1raY8J
相关文章推荐
- Nios程序烧写到EPCS方法 - 第1页 - asus119's Blog - EDN China电子设计技术
- ios开发随笔记(二)
- js和html5实现手机端刮刮卡抽奖效果完美兼容android/IOS
- IOS之Delegate
- ios 使用keychain来存储token
- IOS 后台执行
- IOS , plist 配置项说明
- iOS 友盟错误分析
- 在iOS7中修改键盘Return键的类型
- iOS开发篇——OC 协议和代理设计模式介绍
- espondsToSelector判断是否实现了某方法
- IOS中堆和栈的区别
- iOS 归档和序列化编程指导
- iOS - float数据类型经运算后变成 nan:
- 运维监控部署-nagios_7.触发间隔
- 运维监控部署-nagios_6.监控设置
- IOS开发数据传递机制之NSNotificationCenter
- 运维监控部署-nagios_5.cacti-plugins
- 运维监控部署-nagios_4.安装cacti
- 运维监控部署-nagios_3.安装邮件系统