sounds images and text n.
Skip this Video
Loading SlideShow in 5 Seconds..
Sounds, Images, and Text PowerPoint Presentation
Download Presentation
Sounds, Images, and Text

Loading in 2 Seconds...

play fullscreen
1 / 13

Sounds, Images, and Text - PowerPoint PPT Presentation

  • Uploaded on

Sounds, Images, and Text. FA 172 Intro to Mobile App Development. Agenda. Sounds System Sound Services Images Image View and the UIImage class Text Files, parsing, Web access. Sounds. Reference:

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Sounds, Images, and Text' - kare

Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
sounds images and text

Sounds, Images, and Text

FA 172

Intro to Mobile App Development

  • Sounds
    • System Sound Services
  • Images
    • Image View and the UIImageclass
  • Text
    • Files, parsing, Web access
  • Reference:
  • Various ways to play sound, depending on format, length, and whether you want sounds played in the background
  • For this class, we will use System Sound Services via the AudioToolboxlibrary
setting up and playing sounds
Setting up and playing sounds
  • Set up
    • Define sound id
      • SystemSoundId _soundId;
    • Specify sound file
      • NSString *file = [[NSBundlemainBundle] pathForResource: @"soundfile" ofType:@"wav"];
      • NSURL *url =[NSURL fileURLWithPath:file];
    • Associate with sound id
      • AudioServicesCreateSystemSoundID((CFURLRef) url, &_soundId);
  • Play
    • Play by indicating sound id
      • AudioServicesPlaySystemSound(_soundId);
sounds class
Sounds class
  • A Sounds class (Sounds.h, Sounds.m) has been provided that enables sound support
    • You are welcome to look at the implementation but do not need to as long as you understand how to invoke the methods
  • Class methods:
    • setSound: associate a sound file to an idNum (int)
    • play: plays the sound by indicating the idNum
  • Make sure to
    • Include AudioToolbox library in frameworks(Build Phases, Link Binary with Libraries)
    • Include sound files in “Supporting Files”
class methods revisited
Class methods revisited
  • Take note: the methods of the Sounds class are class methods
  • .h file (interface) contains method declarations with the + prefix
  • When using the class, [Sounds <method>];
    • e.g.,[Sounds setSound: 3: @"file”: @"wav"];[Sounds play: 3];
  • Image View
    • Displays an image or animation (described by several images)
    • Placed within a UI View of a View Controller
  • Associated image can be assigned either
    • Through the Xcode environment: through attributes inspector
    • Or programmatically, by setting properties or calling methods on the UIImageView outlet connection
  • Set image of image view by assigning a UIImage object to the view’s image property

self.imageView.image =


  • Make sure all image files needed are included in the “Supporting Files” area (and added to the project’s target
  • Set up an NSArray of images representing the images describing the animation
  • Set two properties of the view
    • animationImages: the NSArray
    • animationDuration: number representing the duration (in seconds) for one animation cycle
  • Call startAnimating method on the view
  • Call stopAnimating method to stop animation
animation example
Animation Example

NSArray *images = [NSArrayarrayWithObjects:





self.iv.animationImages = images;

self.iv.animationDuration = 0.5;


  • Create a single view project with three buttons and one image view
    • Set the image of the view to some default image
  • Button 1: changes the image to the another image
  • Button 2: plays a sound
  • Button 3: plays a different sound and then runs an animation
  • The project requires 2 sounds and at least 4 images
  • Demonstrated through a sample project
  • Text files: read/write text (NSString*) from/to files
  • Parsing: from NSString to NSArray
  • Reading data from the web
  • To be posted on the website
  • Sounds in an app can be played throughSystems Sound Services using the AudioToolbox library
    • Other frameworks are available
    • A Sounds class enabling sound support has been created for this course to simplify use
  • Images and animation supported through
    • UIImageView class
    • UIImage class