iPhone - some sound files not playing

前端 未结 2 1504
醉酒成梦
醉酒成梦 2020-12-17 06:59

I have a list of short wav files. Two of these files do not play on either the simulator or the device itself. All are wav files 1 second long.

This is how I play th

相关标签:
2条回答
  • 2020-12-17 07:19

    See this question Trying to play sound through iPhone Simulator

    I've had a lot more success with .aiff files.

    It would be good to know what exactly AudioServicesCreateSystemSoundID is checking when a file is passed to it.

    0 讨论(0)
  • 2020-12-17 07:25

    The iPhone only supports the following codecs:

    • AMR (Adaptive Multi-Rate, a speech codec)
    • iLBC (internet Low Bitrate Codec, also a speech codec)
    • IMA/ADPCM (also known as IMA-4)
    • Linear PCM
    • µLaw and aLaw

    Your WAV files may contain audio that is in a different format, so even though the iPhone supports WAV files, it might not support your specific WAV file.

    The best option is normally to use the command line program "afconvert" to convert everything to CAF files (which is Apple's default format). e.g.:

    afconvert sound1.wav sound1.caf
    

    the full set of conversion options can be listed by running:

    afconvert -h
    

    This conversion will be lossless from most formats. The CAF file format is normally the fastest and lowest overhead to use on the iPhone.

    0 讨论(0)
提交回复
热议问题