//
// SampleDay9_2ViewController.h
// SampleDay9-2
//
// Created by bit on 11. 5. 26..
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import
#import
@interface SampleDay9_2ViewController : UIViewController {
MPMoviePlayerController* player;
}
-(IBAction)onStart:(id)sender;
-(void)movieFinishCallback:(NSNotification*)aNotification;
@end
//
// SampleDay9_2ViewController.m
// SampleDay9-2
//
// Created by bit on 11. 5. 26..
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "SampleDay9_2ViewController.h"
// include 를 추가한다...
// SDK 에 Media Framework 를 추가 한다.
#import
@implementation SampleDay9_2ViewController
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
-(void)movieFinishCallback:(NSNotification*)aNotification
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];
}
-(IBAction)onStart:(id)sender
{
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"m4v"];
NSURL *url = [NSURL fileURLWithPath:moviePath];
// 서버에 리모트로 접근시
// NSURL *url = [NSURL URLWithString:moviePath];
MPMoviePlayerViewController *mpView = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
//self.player = mpView.moviePlayer;
[self presentModalViewController:mpView animated:YES];
}
@end
댓글 없음:
댓글 쓰기
참고: 블로그의 회원만 댓글을 작성할 수 있습니다.