IOS audio playback-Summary

Source: Internet
Author: User

IOS audio playback

Sound support is essential in the development of iPhone applications or games. Each of the several applications I have done involves sound effects, so here is a simple induction, many of them refer to the iPhone application programming guide (which requires an Apple ID to open the link) and add some practical experience.
IPhone OS mainly provides the following methods for playing audio:
System sound services
Avaudioplayer class
Audio queue services
Openal


1. system sound services
system sound services is the most basic and simple sound playback service. You can call audioservicesplaysystemsound to play some simple audio files, this method is only suitable for playing small prompts or warning sounds, because it has many restrictions:
■ The sound length must be less than 30 seconds
■ in linear PCM or ima4 (IMA/ADPCM) format
■ package. CAF ,. AIF, or. W AV files
■ playback progress cannot be controlled
■ play a sound immediately after calling the method
■ No loop playback or stereo Control
In addition, it can also call the system vibration function, and the method is also very simple. For more information about Code , see syssound
, however, the official examples only have some simple usage. From the documentation, we can add the callback function for audio playback through the audioservicesaddsystemsoundcompletion method. With the callback function, we can solve many problems, for example, system sound services does not support loop playback. The following code implements a background music loop in the Program :


?
12345678910111213141516171819202122232425262728293031 Static

Void

Completioncallback (systemsoundid myssid ){
//
Play again after Sound Play completion
Audioservicesplaysystemsound (myssid );
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.