1 / 46
文档名称:

[斯坦福大学iPhone开发教程2010年冬].Lecture.16.Slides.(February.25,.2010).pdf

格式:pdf   页数:46
下载后只包含 1 个 PDF 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

[斯坦福大学iPhone开发教程2010年冬].Lecture.16.Slides.(February.25,.2010).pdf

上传人:kuo08091 2013/12/13 文件大小:0 KB

下载得到文件列表

[斯坦福大学iPhone开发教程2010年冬].Lecture.16.Slides.(February.25,.2010).pdf

文档介绍

文档介绍:CS193P - Lecture 16
iPhone Application Development
Audio APIs
Video Playback
Displaying Web Content
Settings
Tuesday, March 2, 2010 1
Today’s Topics
• Audio APIs
• Video Playback
• Settings Bundles
Tuesday, March 2, 2010 2
Audio Playback
Tuesday, March 2, 2010 3
Uses for Audio
• Sound effects
■ button clicks
■ alert sounds
■ short sounds panying user actions
• Arbitrary length sounds (music, podcasts, spoken content)
• Streamed content from web services
• Recording audio
Tuesday, March 2, 2010 4
How to do it?
• Could plex:
■ Potentially multiple simultaneous sources
■ Numerous possible outputs
■ Dynamic events, often out of user’s control
■ Different priorities for seemingly similar actions
• The OS manages the sound system
■ You can ask for behavior, but the OS has control
Tuesday, March 2, 2010 5
CoreAudio
• High level, easy to use
■ System Sound API - short sounds
■ AVAudioPlayer class - ObjC, simple API
• Lower level, takes more effort but much more control
■ Audio Toolbox - recording and playback, streaming, full control
■ Audio Units - processing audio
■ OpenAL - 3D positional sound
• Which one you use depends on what you’re trying to do
■ Many of you are fine with System Sounds and AVAudioPlayer
Tuesday, March 2, 2010 6
Playing Short Sounds
•“short” means less than 5 seconds
• Very simple API, but has restrictions
■ No looping
■ No volume control
■ Immediate playback
■ Limited set of formats
■ Linear PCM or IMA4
■.caf, .aif or .wav file
Tuesday, March 2, 2010 7
Playing Short Sounds
• Two step process
■ Register the sound, get a “sound ID” in return
■ Play the sound
■ Optionally can get callback when sound finishes playing
NSURL *fileURL = ... // url to a file
SystemSoundID myID;
// First register the sound
AudioServicesCreateSystemSoundID ((CFURLRef)fileURL, &myID);
// Then you can play the sound
AudioServicesPlaySystemSound (myID);
Tuesday, March