{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

16-AudioVideoWeb

16-AudioVideoWeb - CS193P Lecture 16 iPhone Application...

Info icon This preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
CS193P - Lecture 16 iPhone Application Development Audio APIs Video Playback Displaying Web Content Settings
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Announcements Final projects due in 11 days Sunday, June 7, 11:59 pm Submit: Code Power-point slides ReadMe file Final project demos June 8, from 12:15 - 3:15 pm 2 minute presentation, followed by demo-fair Rapid-fire!! Time limit strictly enforced Apps optionally made available to your classmates
Image of page 2
Announcements AdWhirl outside after class Free Jamba Juice! Find out how to add advertising into your app Meet Eddie & James CS193p alumni Authors of Air Guitar & Shotgun Free
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Audio APIs Video Playback UIWebView Settings Bundles Today’s Topics
Image of page 4
Audio
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Uses for Audio Sound effects button clicks alert sounds short sounds accompanying user actions Arbitrary length sounds (music, podcasts, spoken content) Streamed content from web services Recording audio
Image of page 6
How to do it? Could be complex: 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
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
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
Image of page 8
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
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
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);
Image of page 10
Playing Short Sounds Clean up Dispose of sound ID when you’re done Or if you get a memory warning SystemSoundID myID; // dispose of the previously registered sound AudioServicesDisposeSystemSoundID (myID);
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Feel the vibration System sound API allows for triggering the phone’s vibration Use the special system sound ID kSystemSoundID_Vibrate Does nothing on iPod touch - (void)vibrate { // trigger the phone’s vibration AudioServicesPlaySystemSound ( kSystemSoundID_Vibrate ); }
Image of page 12
Converting Sounds Command line utility to convert sounds /usr/bin/afconvert Supports wide variety of input and output formats See man page for details Easily convert sounds to System Sounds formats /usr/bin/afconvert -f aiff -d BEI16 input.mp3 output.aif
Image of page 13

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}