2012-03-17 2 views
0

나는 동영상보기 상단에 "재생 심볼"을 얻는 방법을 알아 내려고 했으므로 사용자는이를 눌러 비디오를 시작해야합니다. 아무도 그것을 구현하는 방법을 알고 있습니까?무비 플레이어 iOS5에서 심볼을 재생

-(void)viewDidLoad 
{ 
//Video player 
NSString *url = [[NSBundle mainBundle] pathForResource:self.navigationItem.title ofType:@"mov"]; 

_player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath: url]]; 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:_player]; 
_player.view.frame = CGRectMake(350, 200, 400, 400); 
[self.view addSubview:_player.view]; 
} 

//Plays the movie once the "Play" button is pressed 
-(IBAction)playMovie 
{ 
[_player play]; 
} 

//Exits fullscreen when movie is finished 
- (void) playerPlaybackDidFinish:(NSNotification*)notification 
{ 
_player.fullscreen = NO; 
} 

답변

0

당신은 당신의 버튼 함께 IBOutlet을 만들 수 있습니다 또는 당신이 ...이 같은 코드를 통해 재생 버튼을 직접 추가해야합니다 (코드를 통해 액세스하기 위해.)

// Add play button 
    playButton = [[UIButton alloc] initWithFrame:CGRectMake(53, 212, 214, 36)];  
    [playButton setBackgroundImage:[UIImage imageNamed:@"playButton.png"] forState:UIControlStateNormal]; 
    [playButton addTarget:self action:@selector(buttonPressed:) forControlEvents: UIControlEventTouchUpInside];  
    [[self view] addSubview:playButton]; 

당신이보기에 movieplayer를 추가 완료되면하고 .... 당신은 당신이보기에 movieplayer을 추가 한 후 수행 할

[self.view bringSubviewToFront:playButton]; 

이 기억 .... 전면 등으로을 playButton 가져와야 ...

소스 ... http://iosdevelopertips.com/video/getting-mpmovieplayercontroller-to-cooperate-with-ios4-3-2-ipad-and-earlier-versions-of-iphone-sdk.html

관련 문제