2011-02-18 6 views
-1

내 응용 프로그램에서 2 개의 URL 비디오를 차례로 재생하고 싶습니다. url에서 2 비디오를 하나씩 재생

내 코드입니다 :

`- (무효)의 viewDidLoad {

NSLog(@"viewDidLoad"); 
player = [[MPMoviePlayerController alloc] initWithContentURL:[self movieURL]]; 

[NSNotificationCenter defaultCenter]addObserver:self 
             selector:@selector(movieFinishedCallback:) 
              name:MPMoviePlayerPlaybackDidFinishNotification 
              object:player]; 
[player play]; 

[슈퍼 vieDidLoad] 하나 개의 URL 비디오 난 다음 URL 비디오를 재생하려는 완료

`

후 }

- (NSURL *)movieURL { 

return [NSURL URLWithString: @"https://s3.amazonaws.com/adplayer/colgate.mp4"];//First video url after this video complete.I want to play the next url video. 

}

- (void) movieFinishedCallback:(NSNotification*) aNotification { 

NSLog(@"movieFinishedCallback"); 
player = [aNotification object]; 
[[NSNotificationCenter defaultCenter] 
removeObserver:self 
name:MPMoviePlayerPlaybackDidFinishNotification 
object:player];  
[player autorelease]; 

}.

제발 도와주세요.

내가 저장이이 같은 배열의 URL의, 그리고

array=[[NSArray alloc] initWithObjects:@"https://s3.amazonaws.com/adplayer/colgate.mp4",@"https://s3.amazonaws.com/ventuno-platform-flv-sep2010/happy_family.mp4",nil]; 

은 내가 어떻게에 URL을 가져 오지 수 있습니다 - (무효) movieFinishedCallback : (NSNotification *) aNotification {

} method.please주고 나에게 이것에 대한 안내.

답변

1

나는 그것을 테스트하지는 않았지만 효과가있다. 조금 수정해야 할 수도있다. 적어도, 당신은 지금이 작업을 수행 할 수 있습니다, 어떻게 아이디어가

-(void)viewDidLoad 
{ 
    [self initializPlayer]; 
} 



static int i; 
-(void)initializPlayer 
{ 
    if(i<=[arrMovieURL count]) 
     i +=1; 
    else { 
     i = 0; 
    } 

    if(player) 
    { 
     [player release]; 
     player = nil; 
    } 
    player = [[MPMoviePlayerController alloc] initWithContentURL:[arrMovieURL objectAtIndex:i]]; 

    [NSNotificationCenter defaultCenter]addObserver:self 
    selector:@selector(movieFinishedCallback:) 
    name:MPMoviePlayerPlaybackDidFinishNotification 
    object:player]; 

    [player play]; 
} 


- (void) movieFinishedCallback:(NSNotification*) aNotification { 

NSLog(@"movieFinishedCallback"); 
player = [aNotification object]; 
[[NSNotificationCenter defaultCenter] 
removeObserver:self 
name:MPMoviePlayerPlaybackDidFinishNotification 
object:player];  

//calling again to play the next video 
    [self initializPlayer]; 
} 
+0

@Harinder : 내가 PIN이 수 어떻게 array.and에 URL을 저장하는 방법의 URL의 한 부탁 이오에 의해 나에게 샘플 code.please을 제공 내 인생을 구하십시오. 감사합니다 – kanmani

+0

@Harinder : 제 질문을 편집했습니다. 친절하게도 그것을 참조하고 저를 안내합니다. – kanmani

+0

당신의 질문은 실제로 영화를 보는 것과 아무 관련이 없지만, 매우 기본적인 Objective-C입니다./Foundation 프레임 워크 질문. Objective-C 프로그래밍에 대한 소개 책을 준비하는 것이 좋습니다. –

관련 문제