zoukankan      html  css  js  c++  java
  • iOS开发总结(A0)- AVAudioPlayer

    AVAudioPlayer是AVFoundation框架中播放音频的一个类 

    每个AVAudioPlayer对应一个音频,主要创建方法为

    - (instancetype)initWithContentsOfURL:(NSURL *)url error:(NSError **)outError;
    
    - (instancetype)initWithData:(NSData *)data error:(NSError **)outError;

    推荐格式:

    - 对于非压缩音频,caf格式(16-bit, little endian,linear PCM)

    -对于压缩音频,且一次播放一个音频,使用caf,或者m4a格式

    - 若同时播放多个声音,考虑降低内存,可使用IMA4压缩,使用caf格式

    可使用mac afconvert 命令转换格式

    1. cd 到需要转换的文件目录下

    2. 命令格式为 afconvert [option...] input_file [output_file],option的形式是 

    3. 比如afconvert -f caff -d LEI16 {INPUT} {OUTPUT} 转换为use 16-bit, little endian, linear PCM  caf文件

    AVAudioPlayer主要的播放方法:

    @property NSTimeInterval currentTime;
    
    - (BOOL)play; /* sound is played asynchronously. */
    
    - (BOOL)playAtTime:(NSTimeInterval)time NS_AVAILABLE(10_7, 4_0); /* play a sound some time in the future. time is an absolute time based on and greater than deviceCurrentTime. */
    
    - (void)pause; /* pauses playback, but remains ready to play. */
    
    - (void)stop; /* stops playback. no longer ready to play. */
    
    
  • 相关阅读:
    关于jquery判断对象是否为空
    php设计模式学习之观察者模式
    php设计模式学习之单例模式
    Nginx+phpfastcgi下flush输出问题
    php设计模式学习之工厂模式
    centos设置ssh免密码登陆
    关于yii2自带验证码功能不显示问题
    html原样输出html代码
    centos7安装iptables
    centos下配置nginx支持php
  • 原文地址:https://www.cnblogs.com/beddup/p/4621566.html
Copyright © 2011-2022 走看看