CS193p Spring 2010 Wednesday, May 26, 2010

Similar documents
CS193P - Lecture 16. iphone Application Development. Audio APIs Video Playback Displaying Web Content Settings

Announcements. Today s Topics

AVAudioPlayer. avtouch Application

} override func didreceivememorywarning() { 26 super.didreceivememorywarning() 27 } 28 } Pause Stop

ITP 342 Mobile App Dev. Audio

AVAudioRecorder & System Sound Services

Announcements. Today s Topics

Media Playback and Recording. CS193W - Spring Lecture 3

CS193p Spring 2010 Thursday, April 29, 2010

Create an App that will drop PushPins onto a map based on addresses that the user inputs.

Introducing MusicKit. Media #WWDC17. Tim Parthemore, MusicKit Services Joel Lopes Da Silva, ios Music

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

Stanford CS193p. Developing Applications for ios Fall Stanford CS193p. Fall 2013

Cisco StadiumVision Mobile API for Apple ios

ipod shuffle User Guide

Localizing with Xcode 6

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

CS193p Spring 2010 Wednesday, March 31, 2010

Portable audio PORTABLE AUDIO. Portable audio overview

CS378 -Mobile Computing. Audio

Cisco StadiumVision Mobile API for Apple ios

Assignment II: Foundation Calculator

ADDING MUSIC TO YOUR itunes LIBRARY

CS193P - Lecture 11. iphone Application Development. Text Input Presenting Content Modally

MBS Xojo AudioPlayer Kit

Listening to Music and Other Audio Files

CS193E Lecture 7. Document-based Applications NSTableView Key-Value Coding

What s New in Core Audio

ITP 342 Mobile App Dev. Audio

AUDIO VIDEO & NAVIGATION SYSTEM OWNER S MANUAL

iphone Programming Touch, Sound, and More! Norman McEntire Founder Servin Flashlight CodeTour TouchCount CodeTour

Developing Applications for ios

Portable audio PORTABLE AUDIO

User Manual Gregor Krasevec. designed and created by.

How to Make a Podcast

Stanford CS193p. Developing Applications for ios. Spring Stanford CS193p. Spring 2012

HKUST. CSIT 6910A Report. iband - Musical Instrument App on Mobile Devices. Student: QIAN Li. Supervisor: Prof. David Rossiter

Delivering an Exceptional Audio Experience

CS193P - Lecture 13. iphone Application Development. Address Book - Putting People in Your App

Agenda. Core Data! Next Week! Storing your Model permanently in an object-oriented database.! Multitasking! Advanced Segueing! Map Kit?

Adobe Primetime TVSDK 1.4 for ios Programmer's Guide

Application Control... 5 Zoom... 5 Exit... 5 Expand... 5 Minimize... 6 Administration... 7 Logging In... 7 Accessing Administration...

Announcements. Paparazzi 3 assignment is due Wednesday 2/17 This Friday s extra session will feature Evan Doll

Amazing Audacity: Session 1

Homework 4 - MediaPlayer and Service

Media Playback and The Top Shelf. CS193W - Spring Lecture 8

Cocoa, Objective C - Alert Panels!

ios SDK API Reference Guide mpos Thermal Printer BGT-100P / BGT-102P SRP-Q300 / SRP-Q302

User Manual Gregor Krasevec. designed and created by.

Multimedia. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

LP2CD Wizard 2.0 User's Manual

Getting Started Movies MediaPlayer is required to use Maestro for movies. Note: Live Search: Main Movie Menu List / Cover View: Sort:

Functional Reactive Programming on ios

CS193P - Lecture 11. iphone Application Development. Text Input Presenting Content Modally

Mobile Application Development L14: Miscellaneous

Compact disc player LOADING COMPACT DISCS. CAUTIONS Do not force the disc into the slot.

Announcement. Final Project Proposal Presentations and Updates

CS193E Lecture 16. Internationalization and Localization

Compact disc player LOADING COMPACT DISCS

ipod classic User Guide

ipod nano User Guide

Podcasting With GarageBand 09

Digital Music. You can download this file from Dig Music May

WatchKit In-Depth, Part 2

Multitasking and Background Execution

ios Mobile Development

CS 1803 Pair Homework 3 Calculator Pair Fun Due: Wednesday, September 15th, before 6 PM Out of 100 points

App SandBox Directory

The Sensors in your iphone. Dr Alasdair Allan

PLUX ios Application Programming Interface. Documentation - ios API

Getting Help. iphone Application Programming Lecture 3: Foundation Classes. Data Structures in Objective C. Online Documentation.

NoteBurner itunes DRM Audio Converter for Windows. Tutorial of NoteBurner itunes DRM Audio Converter for Windows

ESKIAV2 (SQA Unit Code - F9AL 04) Audio and Video Software

iphone Application Programming Lecture 3: Foundation Classes

Using the MP3 Player on the SpringBoard Lite, Vantage Lite and Vanguard communication devices

Advances in AVFoundation Playback

The Tracks Tab. Fingerprinting & Metadata Management

CD Audio Ripping for use with Pricom DreamPlayer

CS193P - Lecture 7. iphone Application Development. Navigation & Tab Bar Controllers

2.1.1 User Manual.

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010

Multi-Room Music Servers

Gentle G192 Media Options

CS1 Lecture 3 Jan. 18, 2019

TunePat Spotify Converter for Windows. User Manual

Introducing CloudKit. A how-to guide for icloud for your Apps. Frameworks #WWDC14. Session 208 Olivier Bonnet CloudKit Client Software

Getting Help. iphone Application Programming Lecture 3: Foundation Classes. Data Structures in Objective C. Online Documentation.

& Windows XP. ESC 12/Podcasting Workshop Handout/June 2009/Exec Svcs Tech/Rev 2

CIS 408 Internet Computing Sunnie Chung

Mobile Application Development

NoteBurner Spotify Music Converter for Windows. Tutorial of NoteBurner Spotify Music Converter for Windows

What's new in ios 5?

Digital Video Act II Introduction to Editing and Distribution. University of Utah Student Computing Labs Macintosh Support

Core Data Potpourri. Paul

HELLOMOTO. contents MOTO U9

TEAC HR Audio Player. Music Playback Software for TEAC USB AUDIO DAC Devices OWNER S MANUAL

Patterns Continued and Concluded. July 26, 2017

Objective-C Part 2 (ECS189H) Ken Joy Serban Porumbescu

Introducing the Modern WebKit API

Digital Video Editing Using imovie

Transcription:

CS193p Spring 2010

Announcements Please e-mail if you want to take the option to present your final project next Wednesday. (You will still have until the following Tuesday to turn in your code.) No class on Monday. Always interested in feedback for future versions of the class. Share by e-mail or your submission README. If you are interested in TA position for Fall Quarter, please let me know.

Today s Topics: Audio Music Library (ipod) Connectivity Playing/Recording Audio

MediaPlayer Access tracks in ipod music library Can play them, but can t copy the data out View Controller to pick tracks Can also find tracks using a query API Like NSPredicate, but customized for music.

MediaPlayer MPMediaPickerController Present it modally. Initialize with the desired media types MPMediaPickerController *picker = [[MPMediaPickerController alloc] initwithmediatypes:(mpmediatype)mediatypes]; MPMediaTypeMusic MPMediaTypePodcast MPMediaTypeAudioBook MPMediaTypeAnyAudio Set whether more than one track can be chosen picker.allowspickingmultipleitems = (BOOL); And a title for the picker (looks better if nil) picker.prompt = (NSString *);

MediaPlayer Set delegate and then put it on screen [self presentmodalviewcontroller:picker animated:yes]; Initialize with the desired media types - (void)mediapicker:(mpmediapickercontroller *)picker didpickmediaitems:(mpmediaitemcollection *)chosenitems; MPMediaItemCollection @property (NSArray *)items; // of MPMediaItem @property (NSUInteger)count; @property (MPMediaType)mediaTypes; @property MPMediaItem *representativeitem; // album, artist, genius, etc. MPMediaItem - (id)valueforproperty:(nsstring *)propertyname; + (BOOL)canFilterByProperty:(NSString *)propertyname; (whether property can be used to build MPMediaPropertyPredicate)

MediaPlayer MPMediaItem properties Filterable: MPMediaItemPropertyPersistentID; MPMediaItemPropertyMediaType; MPMediaItemPropertyTitle; MPMediaItemPropertyAlbumTitle; MPMediaItemPropertyArtist; MPMediaItemPropertyAlbumArtist; MPMediaItemPropertyGenre; MPMediaItemPropertyComposer; MPMediaItemPropertyIsCompilation; // NSNumber (64-bit long) // NSNumber // NSNumber (boolean) Non-filterable: MPMediaItemPropertyPlaybackDuration; // NSNumber (seconds) MPMediaItemPropertyAlbumTrackNumber; // NSNumber MPMediaItemPropertyAlbumTrackCount; // NSNumber MPMediaItemPropertyDiscNumber; // NSNumber MPMediaItemPropertyDiscCount; // NSNumber MPMediaItemPropertyArtwork; // MPMediaItemArtwork MPMediaItemPropertyLyrics;

MediaPlayer Searching the Media Library Create an MPMediaQuery There are some pre-canned ones (class methods on MPMediaQuery) + (MPMediaQuery)albumsQuery; + (MPMediaQuery)artistsQuery; Or you can build your own using MPMediaPropertyPredicate class... MPMediaPropertyPredicate *beatlesalbums = [MPMediaPropertyPredicate predicatewithvalue:@ Beatles forproperty:mpmediaitempropertyartist comparisontype:nsmediapredicatecomparisoncontains]; MPMediaQuery *query = [[MPMediaQuery alloc] init]; query.filterpredicates = [NSSet setwithobject:beatlesalbums]; query.groupingtype = MPMediaGroupingAlbum; This query will get an array of groups of songs by the Beatles. In this case, the songs will be grouped by the album they were on. If we grouped by artist, it d be an array with one group of songs in it.

MediaPlayer Then just ask the the MPMediaQuery for matches - (NSArray *)collections; // of MPMediaItemCollection Look at representativeitem to tell which is which NSArray *albums = [query collections]; for (MPMediaItemCollection *album in albums) { NSString *albumtitle = [albums.representativeitem valueforproperty:mpmediaitempropertyalbum]; NSLog(@ album = %@, albumtitle); }

MediaPlayer Playing the chosen or queried music Get your application s MPMusicPlayerController MPMusicPlayerController *mpc = [MPMusicPlayerController applicationmusicplayer]; Tell it which collection of items to play [mpc setqueuewithitemcollection:(mpmediaitemcollection *)collection];... or... [mpc setqueuewithquery:(mpmediaquery *)aquery]; Then tell it to play (or rewind or pause) [mpc play]; [mpc pause]; [mpc beginseekingbackward]; [mpc endseeking]; [mpc skiptonextitem];

MediaPlayer Finding out what s playing MPMediaItem *nowplaying = mpc.nowplayingitem; Finding out where in the track we are NSTimeInterval position = mpc.currentplaybacktime; This is read/write, so hook up to a slider and scrub with it! Playing right now? Paused? Rewinding? MPMusicPlaybackState state = mpc.playbackstate; Finding out when play state or now playing changes [[NSNotificationCenter defaultcenter] addobserver:self selector:@selector(ipodplaystatechanged:) name:mpmusicplayercontrollerplaybackstatedidchangenotification object:[mpmusicplayercontroller applicationmusicplayer]]; or MPMusicPlayerControllerNowPlayingItemDidChangeNotification if you want

Demo MPMediaPickerController MPMusicPlayerController Scrubbing

Other Audio What if the sounds you want to play aren t in the user s Music Library? Sound effects Pre-recorded music for your application A few different choices System Sound API AVAudioPlayer Audio Units OpenAL We re only going to talk about the first two Check the documentation for the others. Probably too complicated for you to use in your final project.

System Sound API Simplest sound-playing API Short, non-repeating, immediate play, no volume control, AIFF or WAV Register your sound with the system SystemSoundID mysound; NSURL *soundfile = [NSURL URLForString: [[NSBundle mainbundle] pathforresource:@ mysound of Type:@ caf ]]; AudioServicesCreateSystemSoundID((CFURLRef)soundFile, &mysound); Take the ID you get back and use it to play AudioServicesPlaySystemSound(mySound); Free the sound when you are done with it Or when you get a memory warning (since you can easily recreate). AudioServicesDisposeSystemSound(mySound); Vibrate AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); or AudioServicesPlayAlertSound(mySound);

System Sound API Converting from mp3 (or other) to AIFF Only uncompressed formats are supported Command line utility to convert from compressed formats /usr/bin/afconvert -f aiff -d BE16 input.mp3 output.aif

AVAudioPlayer Quite a bit more powerful than System Sound Long sounds okay Looping, seeking, playing and pausing Metering Play multiple sounds at once Object-oriented API Many more sound file formats supported Allocate and init with the sound file s URL NSString *soundfilepath = [[NSBundle mainbundle] pathforresource:@ mysound oftype:@ mp3 ]; NSURL *soundfileurl = [NSURL URLForString:soundFilePath]; AVAudioPlayer *player = [[AVAudioPlayer alloc] initwithcontentsofurl:soundfileurl];

AVAudioPlayer Now play, pause, scrub, control volume if (!player.playing) { [player play]; } else { [player pause]; } - (void)scrub:(uislider *)sender { } player.currenttime = duration * sender.value; // assuming 0.0 to 1.0 player.volume = 0.75; // from 0.0 to 1.0 Delegate to find out errors, finished, interruption - (void)audioplayerdidfinishplaying:(avaudioplayer *) successfully:(bool); - (void)audioplayerdecodeerrordidoccur:(avaudioplayer *) error:(nserror *); - (void)audioplayerbegininterruption:(avaudioplayer *); - (void)audioplayerendinterruption:(avaudioplayer *);

AVAudioRecorder Very similar to AVAudioPlayer Allocate and init with the sound file s URL NSURL *recordingfileurl =...; // usually in documents directory AVAudioRecorder *recorder = [[AVAudioRecorder alloc] initwithurl:recordingfileurl settings:(nsdictionary *)settings error:(nserror **)errorout]; Now record, pause, get position in recording if (!recorder.recording) { [recorder record]; // or recordforduration:(nstimeinterval) } else { [recorder pause]; } @property (readonly) NSTimeInterval currenttime; // note: read only recorder.meteringenabled = YES; // expensive, so only do it if you mean it recorder.updatemeters; float peakpower = [recorder peakpowerforchannel:0]; float averagepower = [recorder averagepowerforchannel:0];

Demo AVAudioRecorder / AVAudioPlayer Searching ipod Library (time permitting)