AVAudioPlayer简易封装
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简易封装的更多相关文章
- 面localStorage用作数据缓存的简易封装
面localStorage用作数据缓存的简易封装 最近做了一些前端控件的封装,需要用到数据本地存储,开始采用cookie,发现很容易就超过了cookie的容量限制,于是改用localStorage,但 ...
- UITextField的简易封装
UITextField的简易封装 效果 源码 https://github.com/YouXianMing/UI-Component-Collection 中的 UITextFieldView // ...
- 对xlslib库与libxls库的简易封装
一.简介 xlslib库是用来创建excel文件.libxls是用来读取excel文件的,在使用C++或者QT语言来设计对excel文件的读取.都需要事先下载这两个库编译成功后再进行程序设计的.之所以 ...
- node.js + mssql 简易封装操作
时间吧,总是这么凑巧,在我学习[node.js]还没几天,我的 Microsoft SQL Server Management Studio 18 就歇菜了,至于怎么歇菜的吧....它可能的意思就是想 ...
- 基于Vue简易封装的快速构建Echarts组件 -- fx67llQuickEcharts
fx67llQuickEcharts A tool to help you use Echarts quickly! npm 组件说明 这本来是一个测试如何发布Vue组件至npm库的测试项目 做完之后 ...
- jQuery版AJAX简易封装
开发过程中,AJAX的应用应该说非常频繁,当然,jQuery的AJAX函数已经非常好用,但是小编还是稍微整理下,方便不同需求下,可以简化输入参数,下面是实例代码: $(function(){ /** ...
- 页面localStorage用作数据缓存的简易封装
最近做了一些前端控件的封装,需要用到数据本地存储,开始采用cookie,发现很容易就超过了cookie的容量限制,于是改用localStorage,但localStorage过于简单,没有任何管理和限 ...
- Nhibernate基础使用教程以及简易封装
1.Nhibernate简介 NHibernate是一个面向.NET环境的对象/关系数据库映射工具.对象/关系数据库映射(object/relational mapping,ORM)这个术语表示一种技 ...
- Linux网络编程8——对TCP与UDP的简易封装
引言 每次使用socket通信,都会有很对相似的操作.本文,会对TCP与UDP通信做一简单封装,并生成动态库. 代码 my_socket.h #ifndef __MY_SOCKET_H__ #defi ...
随机推荐
- springboot-26-springboot 集成rabbitmq
rabbitmq是基于AMQP规范的一个消息代理, 它可以兼容jms, 支持其他语言, 并且可以跨平台 1, 安装 1) 普通安装 度娘: 2) docker 安装 sudo docker run - ...
- springcloud-02-eureka
在dubbo项目中(http://www.cnblogs.com/wenbronk/p/6774539.html), 我们使用了zookeeper作为集群的注册中心, 在springcloud中, 也 ...
- 面试题43:计算多少种译码方式(decode-ways)
这道题是非常典型的DP问题.按照DP的套路,关键是讨论出递推表达式,遍历过程中针对当前字符是否为'0'以及前一个字符为'0',分类讨论得出到目前字符为止最多有多少种译码方式?理清了递推表达式,代码是很 ...
- echarts 雷达图的个性化设置
echarts 雷达图的个性化设置 function test() { let myChart = echarts.init(document.getElementById('levelImage') ...
- WCF异常信息
1.服务“CJ.Demo.Conso.WcfService.EmployeeMngService”有零个应用程序(非基础结构)终结点.这可能是因为未找到应用程序的配置文件,或者在配置文件中未找到与服务 ...
- Javascript Madness: Mouse Events
http://unixpapa.com/js/mouse.html Javascript Madness: Mouse Events Jan WolterAug 12, 2011 Note: I ha ...
- 通过set赋值,与select赋值的区别
---通过set赋值,与select赋值的区别.declare @a int--set @a=(select count(*) from TblStudent)select @a=count(*) f ...
- Jetty源码解析(web.xml的处理机制)
org.eclipse.jetty.webapp 包下的 StandardDescriptorProcessor类.该类对象会在WebAppContext的doStart方法启用 注册了遍历web.x ...
- SpringMVC整合Shiro安全框架(一)
一. 准备工作 1. 本文参考自张开涛的 <跟我学Shiro> 二. 简介 1. Apache Shiro是Java的一个安全框架.可以帮助我们完成:认证.授权.加密.会话管理.与Web集 ...
- Code Signal_练习题_commonCharacterCount
Given two strings, find the number of common characters between them. Example For s1 = "aabcc&q ...