AVAudioPlayer简易封装

[说明]

AVAudioPlayer简易封装,仅仅支持播放,暂停,停止,暂停时候带有渐隐效果,自己用,没有参考价值.

[源码]

https://github.com/YouXianMing/AVAudioPlayer-

一个定时器的封装类源码(该定时器可以指定运行的次数)

//
// SpecialTimer.h
// Music
//
// Created by XianMingYou on 15/4/13.
// Copyright (c) 2015年 XianMingYou. All rights reserved.
// #import <Foundation/Foundation.h> @class SpecialTimer; @protocol SpecialTimerDelegate <NSObject>
@optional
- (void)specialTimer:(SpecialTimer *)specialTimer CurrentCount:(NSInteger)count; @end @interface SpecialTimer : NSObject /**
* 定时器代理
*/
@property (nonatomic, weak) id<SpecialTimerDelegate> delegate; /**
* 重复执行的次数
*/
@property (nonatomic) NSInteger repeatTimes; /**
* 定时器执行的总时间
*/
@property (nonatomic) NSTimeInterval totalDuration; /**
* 激活定时器
*/
- (void)fire; /**
* 让定时器无效
*/
- (void)invalid; @end
//
// SpecialTimer.m
// Music
//
// Created by XianMingYou on 15/4/13.
// Copyright (c) 2015年 XianMingYou. All rights reserved.
// #import "SpecialTimer.h" @interface SpecialTimer () @property (nonatomic) NSInteger count;
@property (nonatomic, strong) NSTimer *timer; @end @implementation SpecialTimer - (void)fire {
// 参数没有配置就返回
if (self.repeatTimes <= || self.totalDuration <= ) {
return;
} // 计数时间间隔
NSTimeInterval timeInterval = self.totalDuration / self.repeatTimes; // 开启定时器
self.timer = [NSTimer scheduledTimerWithTimeInterval:timeInterval
target:self
selector:@selector(timerEvent)
userInfo:nil
repeats:YES];
} - (void)timerEvent {
// 运行代理
if (_delegate || [_delegate respondsToSelector:@selector(specialTimer:CurrentCount:)]) {
[_delegate specialTimer:self CurrentCount:_count];
} _count++;
if (_count >= _repeatTimes) {
_count = ;
[self.timer invalidate];
}
} - (void)invalid {
[self.timer invalidate];
} @end

AVAudioPlayer简易封装的更多相关文章

  1. 面localStorage用作数据缓存的简易封装

    面localStorage用作数据缓存的简易封装 最近做了一些前端控件的封装,需要用到数据本地存储,开始采用cookie,发现很容易就超过了cookie的容量限制,于是改用localStorage,但 ...

  2. UITextField的简易封装

    UITextField的简易封装 效果 源码 https://github.com/YouXianMing/UI-Component-Collection 中的 UITextFieldView // ...

  3. 对xlslib库与libxls库的简易封装

    一.简介 xlslib库是用来创建excel文件.libxls是用来读取excel文件的,在使用C++或者QT语言来设计对excel文件的读取.都需要事先下载这两个库编译成功后再进行程序设计的.之所以 ...

  4. node.js + mssql 简易封装操作

    时间吧,总是这么凑巧,在我学习[node.js]还没几天,我的 Microsoft SQL Server Management Studio 18 就歇菜了,至于怎么歇菜的吧....它可能的意思就是想 ...

  5. 基于Vue简易封装的快速构建Echarts组件 -- fx67llQuickEcharts

    fx67llQuickEcharts A tool to help you use Echarts quickly! npm 组件说明 这本来是一个测试如何发布Vue组件至npm库的测试项目 做完之后 ...

  6. jQuery版AJAX简易封装

    开发过程中,AJAX的应用应该说非常频繁,当然,jQuery的AJAX函数已经非常好用,但是小编还是稍微整理下,方便不同需求下,可以简化输入参数,下面是实例代码: $(function(){ /** ...

  7. 页面localStorage用作数据缓存的简易封装

    最近做了一些前端控件的封装,需要用到数据本地存储,开始采用cookie,发现很容易就超过了cookie的容量限制,于是改用localStorage,但localStorage过于简单,没有任何管理和限 ...

  8. Nhibernate基础使用教程以及简易封装

    1.Nhibernate简介 NHibernate是一个面向.NET环境的对象/关系数据库映射工具.对象/关系数据库映射(object/relational mapping,ORM)这个术语表示一种技 ...

  9. Linux网络编程8——对TCP与UDP的简易封装

    引言 每次使用socket通信,都会有很对相似的操作.本文,会对TCP与UDP通信做一简单封装,并生成动态库. 代码 my_socket.h #ifndef __MY_SOCKET_H__ #defi ...

随机推荐

  1. xgboost与gbdt区别

    1.基分类器的选择:传统GBDT以CART作为基分类器,XGBoost还支持线性分类器,这个时候XGBoost相当于带L1和L2正则化项的逻辑斯蒂回归(分类问题)或者线性回归(回归问题). 2.二阶泰 ...

  2. windows设置多用户模式

    在实际使用我们较多使用的都是windows系统的单用户模式,它意味着当我们登录一个用户的时候如果另外一个用户也在登录,那么就得等待另外一个用户退出后才可以登录我们这个用户,但是实际需求中,我们经常会遇 ...

  3. C++中指针和引用、数组之间的区别

    指针指向一块内存,它的内容是所指内存的地址:而引用则是某块内存的别名,引用初始化后不能改变指向.使用时,引用更加安全,指针更加灵活. 初始化.引用必须初始化,且初始化之后不能呢改变:指针可以不必初始化 ...

  4. C#开发一应用的总结

    要搭建测试环境. Webbrowser使用方面: 重新加载一页面后,要获取新的内容要使用重新使用browser.Document获取: HtmlElement的GetElementsByTagName ...

  5. [转]How to Import a Text File into SQL Server 2012

    Importing a using the OpenRowSet() Function The OPENROWSET bulk row set provider is accessed by call ...

  6. [转] 如何选择正确的Hadoop版本

    Gartner:如何选择正确的Hadoop版本 这份报告的全名是<How to Choose the Right Apache Hadoop Distribution>.主要介绍了企业如何 ...

  7. 撩课-Java每天5道面试题第23天

    146.什么是Spring MVC ?简单介绍下你对springMVC的理解? Spring MVC是一个基于MVC架构的 用来简化web应用程序开发的应用开发框架, 它是Spring的一个模块, 无 ...

  8. JSON.stringify时间的问题

    使用Element UI控件el-date-picker后台传值用到JSON.stringify转换字符串传后台发现输出国际标准时间(ISO),减少了8个小时, 解决方式: 由于JSON.string ...

  9. 微信小程序“满月”:尝鲜之后你还用过它吗?

    距离 2017 年 1 月 9 日微信小程序上线,整整过去了一个月时间.和互联网时代每天出现的众多新鲜事物相似,小程序甫一诞生,立即占据了各大科技媒体网站头屏并引起社交圈的兴奋讨论.由于背靠微信,纷纷 ...

  10. Android 开发中三种多线程

    在开发工程中线程可以帮助我们提高运行速度,Android开发中我知道的线程有四个一个是老生长谈的Thread,第二个是asyncTask,第三个:TimetTask,第四个是Looper,四个多线程各 ...