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. facebook 摘要生成阅读笔记(二) Abstractive Sentence Summarization with Attentive Recurrent Neural Networks

    整体流程与第一篇差不多,只是在encoder和decoder加入了RNN Encoder: 1. ai=xi+li ai=词向量+词在序列中的位置信息(相当于一个权重,[M, 1]) 流程: 先是CN ...

  2. Solidity两个string的比较

    有三种比较方法 方法一:比较string的哈希值方法二:先比较string的长度,再比较每个对应位置的字母是否相同方法三:先比较string的长度,再比较string的哈希值一.比较string的哈希 ...

  3. Math.floor,Math.ceil,Math.rint,Math.round用法

    一.Math.floor函数讲解 floor原意:地板.Math.floor函数是求一个浮点数的地板,就是求一个最接近它的整数,它的值小于或等于这个浮点数.看下面的例子: package com.qi ...

  4. 【angular5项目积累总结】文件下载

    download() { const token = localStorage.getItem('token'); let headers: HttpHeaders = new HttpHeaders ...

  5. How to update Ionic cli and libraries

    1)npm outdated 2)手动修改你项目的package.json文件,找对应的版本号 3)npm update 重新安装包就可以了. 转自:http://devfanaticblog.com ...

  6. 面向连接的传输TCP(一)

    这篇博客主要是对计算机网络自顶向上做的阅读笔记,深入地了解TCP 一.TCP连接 1.特点: a.TCP是面向连接的,因为一个进程在向另一个进程进行数据传输之前必须先要握手,即要互相发送报文,以确认信 ...

  7. graphviz 的绘图布局

          graphviz是贝尔实验室开发的一个开源的工具包,它使用一个特定的DSL(领域特定语言):dot作为脚本语言,然后使用布局引擎来解析此脚本,并完成自动布局. graphviz中包含了众多 ...

  8. Android基础知识你知道多少?

    https://github.com/zhantong/interview/blob/master/Android/Android.md 四大组件是什么? 四大组件的启动方式? Activity生命周 ...

  9. 使用github搭建个人html网站

    前言:搭建个人网站早就想做了,最近有空就宅在家学习,突然发现github就可以搭建个人的纯html网站,于是开始了这项工作.转载请注明出处:https://www.cnblogs.com/yuxiao ...

  10. 移除button点击时的黑边

    input[type=submit], input[type=reset], input[type=button]{ outline:none; filter: chroma(color=#00000 ...