SlideShare a Scribd company logo
1 of 32
Download to read offline
iPhone Developer Basic Program
Day 4 View &ViewController (2)
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
Course Outline
1. Introduction & Xcode
2. Objective-C & Frameworks
3. View &ViewController
4. View &ViewController (2)
5. Submit App Store
Course Outline
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
www.ibluecode.com/training.html
Day 1 - 5 Slide
www.slideshare.net/eakkattiya
Additional Course
eakkattiya@gmail.com
086-6732111
twitter.com/eakkattiya
facebook.com/eakapong.kattiya
Resources
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
UIImagePickerController
Camera & Photo Gallery
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
Storyboard
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
#import <UIKit/UIKit.h>
@interface MediaViewController : UIViewController
<UIImagePickerControllerDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *myImageView;
- (IBAction)selectPhoto:(id)sender;
@end
UIImagePickerController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
@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];
}
@end
UIImagePickerController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
@implementation MediaViewController
-(void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(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];
}
@end
UIImagePickerControllerDelegate
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
NSLog(@"info =%@",[info description]);
NSLog & Description
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
MediaPlayer & AVFoundation
Framework
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
•AV Foundation
Support : .mp3 ,.aac and more..
•MediaPlayer
Support : mov, mp3, mp4, mpv, and 3gp
•Http Live Streaming
Support : .M3U8 and .ts
AUDIO &VIDEO
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
Class : MPMoviePlayerController
Framework : MediaPlayer/MediaPlayer.h
Sample Code : MoviePlayer
Init : - initWithContentOfURL : (NSURL*)
Property : Frame
Method : prepareToPlay / play
MPMoviePlayerController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
การเรียกใช้งาน
1. Add Framework <MediaPlayer>
MPMoviePlayerController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
การเรียกใช้งาน
1. Add Framework <MediaPlayer>
MPMoviePlayerController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
การเรียกใช้งาน
1. Add Framework <MediaPlayer>
MPMoviePlayerController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
การเรียกใช้งาน
1. Add Framework <MediaPlayer>
2. #import <MediaPlayer/MediaPlayer.h>
3. Create NSURL
4. Init MPMoviePlayerViewController
5. call [self presentMoviePlayerViewControllerAnimated:YES] ;
MPMoviePlayerViewController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface MediaViewController : UIViewController
<UIActionSheetDelegate>
{
MPMoviePlayerController *mediaPlayer ;
MPMoviePlayerViewController *mediaPlayerVC ;
}
- (IBAction)playMedia:(id)sender;
- (IBAction)pauseMedia:(id)sender;
@end
MPMoviePlayerController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
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:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Music",
@"Record Sound",
@"Movie",
@"Streaming",
nil];
[action showInView:self.view];
}
-(void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(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];
}
}
@end
UIActionSheet & Delegate
Sunday, June 9, 13
- (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];
}
MPMoviePlayerViewController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
การเรียกใช้งาน
1. Add Framework <MediaPlayer>
2. #import <MediaPlayer/MediaPlayer.h>
3. Create NSURL
4. Init MPMoviePlayerController
5. call setFrame
6. call addSubView
7. call play
MPMoviePlayerController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
- (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];
}
MPMoviePlayerController
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface MediaViewController : UIViewController
<AVAudioPlayerDelegate>
{
AVAudioPlayer *audioPlayer ;
}
- (IBAction)playMedia:(id)sender;
- (IBAction)pauseMedia:(id)sender;
@end
AVFoundation / AVAudioPlayer
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
AVFoundation / AVAudioPlayer
@implementation MediaViewController
- (void)playMedia:(id)sender {
NSURL *url = [[NSBundle mainBundle] URLForResource:@"background"
withExtension:@"mp3"];
NSError *error = nil ;
if(!audioPlayer){
audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url
error:&error];
}
[audioPlayer play];
}
- (IBAction)pauseMedia:(id)sender {
[audioPlayer pause];
}
@end
Sunday, June 9, 13
#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;
@end
AVFoundation / AVAudioRecoder
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
AVFoundation / 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:AVAudioSessionCategoryPlayback
error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
} else {
[self.recordButton setTitle:@"Recording.."];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord
error: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:url
settings:recordSettings
error:nil];
audioRecorder = newRecorder;
audioRecorder.delegate = self;
[audioRecorder prepareToRecord];
[audioRecorder record];
}
}
@end
Sunday, June 9, 13
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
AudioRecorderDelegate
@implementation MediaViewController
-(void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder
successfully:(BOOL)flag
{
NSLog(@"success recording");
}
-(void)audioRecorderEncodeErrorDidOccur:(AVAudioRecorder *)recorder
error:(NSError *)error
{
NSLog(@"fail recording");
}
@end
Sunday, June 9, 13
UIScrollView
Gallery
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
-(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++ ;
}
}
UIScrollView
by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111
Sunday, June 9, 13
by Eakapong Kattiya
Developing iOS Apps : App Store
Add New Application ( iTunes Connect )
Upload required icon and screenshots
Upload Application Binary ( IPA File )
Waiting for app review by apple ( 7 days - Few months)
Sunday, June 9, 13
AppStore
- เปิดตัววันที่ 10 July 2008
- เป็นครั้งแรกและเป็นช่องทางที่ง่ายที่สุดที่จะทําให้นักพัฒนา
สามารถขาย Application ให้กับคน 155 ประเทศทั่วโลก
- ผู้ใช้ 400 ล้านคนที่ีมีบัตร Credit
by Eakapong Kattiya
Sunday, June 9, 13
AppStore
5-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 Kattiya
Sunday, June 9, 13

More Related Content

Recently uploaded

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

(1 July 2013) iOS Basic Development 4 - Multimedia

  • 1. iPhone Developer Basic Program Day 4 View &ViewController (2) by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 2. Course Outline 1. Introduction & Xcode 2. Objective-C & Frameworks 3. View &ViewController 4. View &ViewController (2) 5. Submit App Store Course Outline by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 3. www.ibluecode.com/training.html Day 1 - 5 Slide www.slideshare.net/eakkattiya Additional Course eakkattiya@gmail.com 086-6732111 twitter.com/eakkattiya facebook.com/eakapong.kattiya Resources by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 4. UIImagePickerController Camera & Photo Gallery by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 5. Storyboard by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 6. #import <UIKit/UIKit.h> @interface MediaViewController : UIViewController <UIImagePickerControllerDelegate> @property (weak, nonatomic) IBOutlet UIImageView *myImageView; - (IBAction)selectPhoto:(id)sender; @end UIImagePickerController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 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]; } @end UIImagePickerController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 8. @implementation MediaViewController -(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(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]; } @end UIImagePickerControllerDelegate by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 9. NSLog(@"info =%@",[info description]); NSLog & Description by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 10. by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 11. MediaPlayer & AVFoundation Framework by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 12. •AV Foundation Support : .mp3 ,.aac and more.. •MediaPlayer Support : mov, mp3, mp4, mpv, and 3gp •Http Live Streaming Support : .M3U8 and .ts AUDIO &VIDEO by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 13. Class : MPMoviePlayerController Framework : MediaPlayer/MediaPlayer.h Sample Code : MoviePlayer Init : - initWithContentOfURL : (NSURL*) Property : Frame Method : prepareToPlay / play MPMoviePlayerController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 14. การเรียกใช้งาน 1. Add Framework <MediaPlayer> MPMoviePlayerController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 15. การเรียกใช้งาน 1. Add Framework <MediaPlayer> MPMoviePlayerController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 16. การเรียกใช้งาน 1. Add Framework <MediaPlayer> MPMoviePlayerController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 17. การเรียกใช้งาน 1. Add Framework <MediaPlayer> 2. #import <MediaPlayer/MediaPlayer.h> 3. Create NSURL 4. Init MPMoviePlayerViewController 5. call [self presentMoviePlayerViewControllerAnimated:YES] ; MPMoviePlayerViewController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 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; @end MPMoviePlayerController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 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:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Music", @"Record Sound", @"Movie", @"Streaming", nil]; [action showInView:self.view]; } -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(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]; } } @end UIActionSheet & Delegate Sunday, June 9, 13
  • 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]; } MPMoviePlayerViewController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 21. การเรียกใช้งาน 1. Add Framework <MediaPlayer> 2. #import <MediaPlayer/MediaPlayer.h> 3. Create NSURL 4. Init MPMoviePlayerController 5. call setFrame 6. call addSubView 7. call play MPMoviePlayerController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 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]; } MPMoviePlayerController by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 23. #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> @interface MediaViewController : UIViewController <AVAudioPlayerDelegate> { AVAudioPlayer *audioPlayer ; } - (IBAction)playMedia:(id)sender; - (IBAction)pauseMedia:(id)sender; @end AVFoundation / AVAudioPlayer by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 24. by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 AVFoundation / AVAudioPlayer @implementation MediaViewController - (void)playMedia:(id)sender { NSURL *url = [[NSBundle mainBundle] URLForResource:@"background" withExtension:@"mp3"]; NSError *error = nil ; if(!audioPlayer){ audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error]; } [audioPlayer play]; } - (IBAction)pauseMedia:(id)sender { [audioPlayer pause]; } @end Sunday, June 9, 13
  • 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; @end AVFoundation / AVAudioRecoder by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 26. by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 AVFoundation / 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:AVAudioSessionCategoryPlayback error:nil]; [[AVAudioSession sharedInstance] setActive:YES error:nil]; } else { [self.recordButton setTitle:@"Recording.."]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error: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:url settings:recordSettings error:nil]; audioRecorder = newRecorder; audioRecorder.delegate = self; [audioRecorder prepareToRecord]; [audioRecorder record]; } } @end Sunday, June 9, 13
  • 27. by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 AudioRecorderDelegate @implementation MediaViewController -(void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag { NSLog(@"success recording"); } -(void)audioRecorderEncodeErrorDidOccur:(AVAudioRecorder *)recorder error:(NSError *)error { NSLog(@"fail recording"); } @end Sunday, June 9, 13
  • 28. UIScrollView Gallery by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 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++ ; } } UIScrollView by Eakapong Kattiya www.ibluecode.com eak.k@ibluecode.com +66 086-673-2111 Sunday, June 9, 13
  • 30. by Eakapong Kattiya Developing iOS Apps : App Store Add New Application ( iTunes Connect ) Upload required icon and screenshots Upload Application Binary ( IPA File ) Waiting for app review by apple ( 7 days - Few months) Sunday, June 9, 13
  • 31. AppStore - เปิดตัววันที่ 10 July 2008 - เป็นครั้งแรกและเป็นช่องทางที่ง่ายที่สุดที่จะทําให้นักพัฒนา สามารถขาย Application ให้กับคน 155 ประเทศทั่วโลก - ผู้ใช้ 400 ล้านคนที่ีมีบัตร Credit by Eakapong Kattiya Sunday, June 9, 13
  • 32. AppStore 5-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 Kattiya Sunday, June 9, 13
  • 41. In-App Purchases (Freemium Model) by Eakapong Kattiya Sunday, June 9, 13
  • 42. In-App Purchases (Tiny Tower) by Eakapong Kattiya Sunday, June 9, 13
  • 43. In-App Purchases Order and Chaos NBA Jam by Eakapong Kattiya Sunday, June 9, 13
  • 44. In-App Purchases (The SmurfsVillage) 8-Year-Old Girl Racks Up $1400 Bill Buying Smurfberries in Smurf's Village by Eakapong Kattiya Sunday, June 9, 13
  • 45. In-App Purchases (Restrictions) by Eakapong Kattiya Sunday, June 9, 13