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

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley 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
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
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
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
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
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
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
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

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