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. */
    
    
  • 相关阅读:
    通俗版说委托
    C#读取配置文件的几种方式
    C#异步了解一下
    C#3DES加密了解一下
    说说泛型
    工厂和抽象工厂
    装饰者模式(Decorator pattern)
    观察者模式(Observer pattern)
    策略模式(Stategy Pattern)
    C#读取Appconfig中自定义的节点
  • 原文地址:https://www.cnblogs.com/beddup/p/4621566.html
Copyright © 2011-2022 走看看