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. 安装scrapy报错 error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

    报错内容:Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools" ...

  2. 值得收藏的TCP套接口编程文章

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由jackieluo发表于云+社区专栏 TCP客户端-服务器典型事件 下图是TCP客户端与服务器之间交互的一系列典型事件时间表: 首先启 ...

  3. 文件触发式实时同步 Rsync+Sersync Rsync+Inotify-tools

    一.概述 1.Rsync+Sersync 是什么? 1)Sersync使用c++编写基于inotify开发的触发机制: 2)Sersync可以监控所监听的目录发生的变化(包括新建.修改.删除),具体到 ...

  4. 将AJAX Post的Data转为对应的Class

    在使用DataTables从服务端获取数据时,在非MVC的情况下没有MVC的自动绑定功能,所以需要自己写一个绑定,将Post过来的InputStream转为对应的类. HTML: <form i ...

  5. 【LeetCode题解】169_求众数(Majority-Element)

    目录 169_求众数(Majority-Element) 描述 解法一:暴力法 思路 Java 实现 Python 实现 复杂度分析 解法二:哈希表 思路 Java 实现 Python 实现 复杂度分 ...

  6. *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<WKWebViewConfiguration 0x1701bcd20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the k

    问题描述: ionic项目,windows下正常,打包android可正常运行: 因为需要打包到iPhone (ios 11.0.1)上测试,将代码拿到Mac OS环境下(重新npm install. ...

  7. sqlserver数据导入导出问题

    sqlserver,如果用结果另存为,导出txt数据,然后在导入数据库,有时候会出问题,很难解决. 但是全选,右击,复制到自己创建的txt里面,在导入数据,就不会有问题的. 神奇,不知道为什么,但是能 ...

  8. 控制台直接执行sql语句

    mysql -h127.0.0.1 -P3306 -uroot -paaccccccc databasename -e "select * from RegInfo where Plat ! ...

  9. CSS选择器深入探讨(细节东西)(转)

    细节决定成败,越是注重细节方面的东西,那么你完成的作品就越完美. 1.父子选择器(看作组合比较好理解) 父子选择器可以有多级(但是在实际开发中最后不好超过三层) 如:html中文件片段: <!- ...

  10. Bash:常用命令工具-uniq

    NAME uniq - report or omit repeated lines SYNOPSIS uniq [OPTION]... [INPUT [OUTPUT]] DESCRIPTION Fil ...