Skip to Main Content
iPhone SDK Programming: Developing Mobile Applications for Apple iPhone and iPod touch
book

iPhone SDK Programming: Developing Mobile Applications for Apple iPhone and iPod touch

by Maher Ali
March 2009
Beginner to intermediate content levelBeginner to intermediate
396 pages
8h 44m
English
Wiley
Content preview from iPhone SDK Programming: Developing Mobile Applications for Apple iPhone and iPod touch

Chapter 13. Working with Devices

In this chapter, we demonstrate the use of the several devices available on the iPhone. Section 13.1 discusses the usage of the accelerometer. In Section 13.2, we show how to play small sound files. Next, Section 13.3 shows how to play video files. After that, Section 13.4 shows how to obtain iPhone/iPod touch device information. Using the camera and the photo library is described in Section 13.5. Finally, we summarize the chapter in Section 13.6

Working with the Accelerometer

The iPhone is equipped with an easy-to-use accelerometer. The accelerometer provides you with the current orientation of the device in 3D space. You subscribe to these updates with a given frequency (10 updates/s to 100 updates/s) and you receive three floating-point values in each update. These values represent the acceleration of x, y, and z in space. The acceleration on each axis is measured in g s, where g is the acceleration due to gravity on earth at sea-level (1g is equal to 9.80 m s−2).

If you hold the iPhone in front of you and imagine an axis that goes through the Home button and the earpiece that is orthogonal to the floor, then that axis is the y-axis. Positive values of y indicate that the phone is accelerating up and negative values indicate that it is accelerating down towards the floor. The x-axis goes from right to left perpendicular to the y-axis. Positive values indicate that the force is towards your right side and negative values indicate that the force is ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft® Office Access 2007 on Demand

Microsoft® Office Access 2007 on Demand

Steve Johnson - Perspection, Inc.
FileMaker Pro 14: The Missing Manual

FileMaker Pro 14: The Missing Manual

Stuart Gripman, Susan Prosser
Microsoft® Office Access™ 2007 Step by Step

Microsoft® Office Access™ 2007 Step by Step

Steve Lambert Joan Lambert and M. Dow Lambert III

Publisher Resources

ISBN: 9780470742822Purchase book