0
iPhone Developer Basic ProgramDay 4 View &ViewController (2)by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 ...
Course Outline1. Introduction & Xcode2. Objective-C & Frameworks3. View &ViewController4. View &ViewController (2)5. Submi...
www.ibluecode.com/training.htmlDay 1 - 5 Slidewww.slideshare.net/eakkattiyaAdditional Courseeakkattiya@gmail.com086-673211...
UIImagePickerControllerCamera & Photo Galleryby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sun...
Storyboardby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
#import <UIKit/UIKit.h>@interface MediaViewController : UIViewController<UIImagePickerControllerDelegate>@property (weak, ...
@implementation MediaViewController- (void)viewDidLoad{[super viewDidLoad];self.navigationController.topViewController.tit...
@implementation MediaViewController-(void) imagePickerController:(UIImagePickerController *)pickerdidFinishPickingMediaWit...
NSLog(@"info =%@",[info description]);NSLog & Descriptionby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086...
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
MediaPlayer & AVFoundationFrameworkby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June ...
•AV FoundationSupport : .mp3 ,.aac and more..•MediaPlayerSupport : mov, mp3, mp4, mpv, and 3gp•Http Live StreamingSupport ...
Class : MPMoviePlayerControllerFramework : MediaPlayer/MediaPlayer.hSample Code : MoviePlayerInit : - initWithContentOfURL...
การเรียกใช้งาน1. Add Framework <MediaPlayer>MPMoviePlayerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.c...
การเรียกใช้งาน1. Add Framework <MediaPlayer>MPMoviePlayerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.c...
การเรียกใช้งาน1. Add Framework <MediaPlayer>MPMoviePlayerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.c...
การเรียกใช้งาน1. Add Framework <MediaPlayer>2. #import <MediaPlayer/MediaPlayer.h>3. Create NSURL4. Init MPMoviePlayerView...
#import <UIKit/UIKit.h>#import <AVFoundation/AVFoundation.h>@interface MediaViewController : UIViewController<UIActionShee...
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111@implementation MediaViewController- (IBAction)p...
- (void)playStreaming{NSURL *url = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_inde...
การเรียกใช้งาน1. Add Framework <MediaPlayer>2. #import <MediaPlayer/MediaPlayer.h>3. Create NSURL4. Init MPMoviePlayerCont...
- (void)playMovie{NSURL *url = [[NSBundle mainBundle] URLForResource:@"movie"withExtension:@"m4v"];mediaPlayer = [[MPMovie...
#import <UIKit/UIKit.h>#import <AVFoundation/AVFoundation.h>@interface MediaViewController : UIViewController<AVAudioPlaye...
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111AVFoundation / AVAudioPlayer@implementation Medi...
#import <UIKit/UIKit.h>#import <AVFoundation/AVFoundation.h>@interface MediaViewController : UIViewController<AVAudioRecor...
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111AVFoundation / AudioRecorder@implementation Medi...
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111AudioRecorderDelegate@implementation MediaViewCo...
UIScrollViewGalleryby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
-(void)initScrollView{NSURL *url = [[NSBundle mainBundle]URLForResource:@"gallery"withExtension:@"plist"];NSArray *items =...
by Eakapong KattiyaDeveloping iOS Apps : App StoreAdd New Application ( iTunes Connect )Upload required icon and screensho...
AppStore- เปิดตัววันที่ 10 July 2008- เป็นครั้งแรกและเป็นช่องทางที่ง่ายที่สุดที่จะทําให้นักพัฒนาสามารถขาย Application ให้ก...
AppStore5-March-2012- จํานวน App รวม (iPhone/iPad/iPodTouch) คือ 550,000+- จํานวน App บน iPad คือ 170,000 +- ยอด AppStore ...
Upcoming SlideShare
Loading in...5
×

(1 July 2013) iOS Basic Development 4 - Multimedia

959

Published on

iOS Basic Development 4 - Multimedia
by Eakapong Kattiya
eakkattiya@gmail.ccom
www.ibluecode.com
+66 086-673-2111

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
959
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
73
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "(1 July 2013) iOS Basic Development 4 - Multimedia"

  1. 1. iPhone Developer Basic ProgramDay 4 View &ViewController (2)by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  2. 2. Course Outline1. Introduction & Xcode2. Objective-C & Frameworks3. View &ViewController4. View &ViewController (2)5. Submit App StoreCourse Outlineby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  3. 3. www.ibluecode.com/training.htmlDay 1 - 5 Slidewww.slideshare.net/eakkattiyaAdditional Courseeakkattiya@gmail.com086-6732111twitter.com/eakkattiyafacebook.com/eakapong.kattiyaResourcesby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  4. 4. UIImagePickerControllerCamera & Photo Galleryby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  5. 5. Storyboardby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  6. 6. #import <UIKit/UIKit.h>@interface MediaViewController : UIViewController<UIImagePickerControllerDelegate>@property (weak, nonatomic) IBOutlet UIImageView *myImageView;- (IBAction)selectPhoto:(id)sender;@endUIImagePickerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  7. 7. @implementation MediaViewController- (void)viewDidLoad{[super viewDidLoad];self.navigationController.topViewController.title = @"Media" ;}- (IBAction)selectPhoto:(id)sender {UIImagePickerController *imagePicker = [UIImagePickerController new];[imagePicker setDelegate:self];if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];}else{[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];}[self presentViewController:imagePicker animated:YES completion:nil];}@endUIImagePickerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  8. 8. @implementation MediaViewController-(void) imagePickerController:(UIImagePickerController *)pickerdidFinishPickingMediaWithInfo:(NSDictionary *)info{[picker dismissViewControllerAnimated:YES completion:nil];NSLog(@"info =%@",[info description]);UIImage *pickedImage = [info valueForKey:@"UIImagePickerControllerOriginalImage"];self.myImageView.image = pickedImage ;}-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{[picker dismissViewControllerAnimated:YES completion:nil];}@endUIImagePickerControllerDelegateby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  9. 9. NSLog(@"info =%@",[info description]);NSLog & Descriptionby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  10. 10. by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  11. 11. MediaPlayer & AVFoundationFrameworkby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  12. 12. •AV FoundationSupport : .mp3 ,.aac and more..•MediaPlayerSupport : mov, mp3, mp4, mpv, and 3gp•Http Live StreamingSupport : .M3U8 and .tsAUDIO &VIDEOby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  13. 13. Class : MPMoviePlayerControllerFramework : MediaPlayer/MediaPlayer.hSample Code : MoviePlayerInit : - initWithContentOfURL : (NSURL*)Property : FrameMethod : prepareToPlay / playMPMoviePlayerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  14. 14. การเรียกใช้งาน1. Add Framework <MediaPlayer>MPMoviePlayerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  15. 15. การเรียกใช้งาน1. Add Framework <MediaPlayer>MPMoviePlayerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  16. 16. การเรียกใช้งาน1. Add Framework <MediaPlayer>MPMoviePlayerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  17. 17. การเรียกใช้งาน1. Add Framework <MediaPlayer>2. #import <MediaPlayer/MediaPlayer.h>3. Create NSURL4. Init MPMoviePlayerViewController5. call [self presentMoviePlayerViewControllerAnimated:YES] ;MPMoviePlayerViewControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  18. 18. #import <UIKit/UIKit.h>#import <AVFoundation/AVFoundation.h>@interface MediaViewController : UIViewController<UIActionSheetDelegate>{MPMoviePlayerController *mediaPlayer ;MPMoviePlayerViewController *mediaPlayerVC ;}- (IBAction)playMedia:(id)sender;- (IBAction)pauseMedia:(id)sender;@endMPMoviePlayerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  19. 19. by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111@implementation MediaViewController- (IBAction)playMedia:(id)sender {UIActionSheet *action = [[UIActionSheet alloc]initWithTitle:@"Select Media"delegate:selfcancelButtonTitle:@"Cancel"destructiveButtonTitle:nilotherButtonTitles:@"Music",@"Record Sound",@"Movie",@"Streaming",nil];[action showInView:self.view];}-(void)actionSheet:(UIActionSheet *)actionSheetclickedButtonAtIndex:(NSInteger)buttonIndex{if(buttonIndex == 0){[self playMusic];}else if(buttonIndex == 1){[self playRecord];}else if(buttonIndex == 2){[self playMovie];}else if(buttonIndex == 3){[self playStreaming];}}@endUIActionSheet & DelegateSunday, June 9, 13
  20. 20. - (void)playStreaming{NSURL *url = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"];mediaPlayerVC = [[MPMoviePlayerViewController alloc]initWithContentURL:url];[self presentMoviePlayerViewControllerAnimated:mediaPlayerVC];}MPMoviePlayerViewControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  21. 21. การเรียกใช้งาน1. Add Framework <MediaPlayer>2. #import <MediaPlayer/MediaPlayer.h>3. Create NSURL4. Init MPMoviePlayerController5. call setFrame6. call addSubView7. call playMPMoviePlayerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  22. 22. - (void)playMovie{NSURL *url = [[NSBundle mainBundle] URLForResource:@"movie"withExtension:@"m4v"];mediaPlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];[mediaPlayer.view setFrame:self.myImageView.bounds];[mediaPlayer prepareToPlay];[self.view addSubview:mediaPlayer.view];}MPMoviePlayerControllerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  23. 23. #import <UIKit/UIKit.h>#import <AVFoundation/AVFoundation.h>@interface MediaViewController : UIViewController<AVAudioPlayerDelegate>{AVAudioPlayer *audioPlayer ;}- (IBAction)playMedia:(id)sender;- (IBAction)pauseMedia:(id)sender;@endAVFoundation / AVAudioPlayerby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  24. 24. by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111AVFoundation / AVAudioPlayer@implementation MediaViewController- (void)playMedia:(id)sender {NSURL *url = [[NSBundle mainBundle] URLForResource:@"background"withExtension:@"mp3"];NSError *error = nil ;if(!audioPlayer){audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:urlerror:&error];}[audioPlayer play];}- (IBAction)pauseMedia:(id)sender {[audioPlayer pause];}@endSunday, June 9, 13
  25. 25. #import <UIKit/UIKit.h>#import <AVFoundation/AVFoundation.h>@interface MediaViewController : UIViewController<AVAudioRecorderDelegate>{AVAudioRecorder *audioRecorder;}@property (weak, nonatomic) IBOutlet UIBarButtonItem *recordButton;- (IBAction)playMedia:(id)sender;- (IBAction)pauseMedia:(id)sender;- (IBAction)recordOrStop:(id)sender;@endAVFoundation / AVAudioRecoderby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  26. 26. by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111AVFoundation / AudioRecorder@implementation MediaViewController- (IBAction) recordOrStop: (id) sender {NSString *soundPath = [NSHomeDirectory()stringByAppendingPathComponent:@"Documentsrecord.caf"];NSURL *url = [NSURL fileURLWithPath:soundPath];if (audioRecorder.isRecording) {[self.recordButton setTitle:@"Stop"];[audioRecorder stop];[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlaybackerror:nil];[[AVAudioSession sharedInstance] setActive:YES error:nil];} else {[self.recordButton setTitle:@"Recording.."];[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecorderror:nil];[[AVAudioSession sharedInstance] setActive:YES error:nil];NSDictionary *recordSettings = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithFloat:44100.0], AVSampleRateKey,[NSNumber numberWithInt:kAudioFormatAppleLossless], AVFormatIDKey,[NSNumber numberWithInt:1], AVNumberOfChannelsKey,[NSNumber numberWithInt:AVAudioQualityMax], AVEncoderAudioQualityKey, nil];AVAudioRecorder *newRecorder = [[AVAudioRecorder alloc] initWithURL:urlsettings:recordSettingserror:nil];audioRecorder = newRecorder;audioRecorder.delegate = self;[audioRecorder prepareToRecord];[audioRecorder record];}}@endSunday, June 9, 13
  27. 27. by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111AudioRecorderDelegate@implementation MediaViewController-(void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recordersuccessfully:(BOOL)flag{NSLog(@"success recording");}-(void)audioRecorderEncodeErrorDidOccur:(AVAudioRecorder *)recordererror:(NSError *)error{NSLog(@"fail recording");}@endSunday, June 9, 13
  28. 28. UIScrollViewGalleryby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  29. 29. -(void)initScrollView{NSURL *url = [[NSBundle mainBundle]URLForResource:@"gallery"withExtension:@"plist"];NSArray *items = [NSArray arrayWithContentsOfURL:url];UIScrollView *scv = [[UIScrollView alloc]initWithFrame:self.view.frame];[scv setContentSize:CGSizeMake(320*items.count, 320)];[scv setPagingEnabled:YES];[self.view addSubview:scv];NSInteger i = 0;for(NSString *imageName in items){UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];[imageView setFrame:CGRectMake(320*i, 0, 320, 320)];[imageView setContentMode:UIViewContentModeScaleAspectFit];[scv addSubview:imageView];i++ ;}}UIScrollViewby Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111Sunday, June 9, 13
  30. 30. by Eakapong KattiyaDeveloping iOS Apps : App StoreAdd New Application ( iTunes Connect )Upload required icon and screenshotsUpload Application Binary ( IPA File )Waiting for app review by apple ( 7 days - Few months)Sunday, June 9, 13
  31. 31. AppStore- เปิดตัววันที่ 10 July 2008- เป็นครั้งแรกและเป็นช่องทางที่ง่ายที่สุดที่จะทําให้นักพัฒนาสามารถขาย Application ให้กับคน 155 ประเทศทั่วโลก- ผู้ใช้ 400 ล้านคนที่ีมีบัตร Creditby Eakapong KattiyaSunday, June 9, 13
  32. 32. AppStore5-March-2012- จํานวน App รวม (iPhone/iPad/iPodTouch) คือ 550,000+- จํานวน App บน iPad คือ 170,000 +- ยอด AppStore Download 25,000 ล้านครั้ง12-June-2012- ปัจจุบันจํานวน App รวม (iPhone/iPad/iPodTouch) คือ 650,000+- จํานวน App บน iPad คือ 225,000 +- ยอด AppStore Download 30,000 ล้านครั้งby Eakapong KattiyaSunday, June 9, 13
  33. 33. AppStoreSunday, June 9, 13
  34. 34. Sunday, June 9, 13
  35. 35. Sunday, June 9, 13
  36. 36. Sunday, June 9, 13
  37. 37. Sunday, June 9, 13
  38. 38. Sunday, June 9, 13
  39. 39. Sunday, June 9, 13
  40. 40. Sunday, June 9, 13
  41. 41. In-App Purchases (Freemium Model)by Eakapong KattiyaSunday, June 9, 13
  42. 42. In-App Purchases (Tiny Tower)by Eakapong KattiyaSunday, June 9, 13
  43. 43. In-App PurchasesOrder and Chaos NBA Jamby Eakapong KattiyaSunday, June 9, 13
  44. 44. In-App Purchases (The SmurfsVillage)8-Year-Old Girl Racks Up $1400 Bill Buying Smurfberries inSmurfs Villageby Eakapong KattiyaSunday, June 9, 13
  45. 45. In-App Purchases (Restrictions)by Eakapong KattiyaSunday, June 9, 13
  46. 46. by Eakapong KattiyaSunday, June 9, 13
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×