2011-02-18 13 views
-1

私のアプリケーションでは、2つのURLビデオを1つずつ再生したいです。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]。 }

- (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]; 

}

`

1つのURLビデオは、私は次のURLビデオを再生したい完了した後。

私を助けてください。

私は、その後どのように私はURLをretriveことができ、

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:私はretriveできるかarray.andでURLのを格納する方法URLの1 one.pleaseによっては私のサンプルcode.pleaseを与えます私の人生を保存してください。ありがとう – kanmani

+0

@Harinder:私は私の質問を編集しました。親切にそれを参照して私を案内します – kanmani

+0

あなたの質問は実際に映画を再生することとは関係ありませんが、代わりに非常に基本的なObjective-/Foundationフレームワークの質問。私はObjective-Cプログラミングの入門書を拾うことをお勧めします。 –

関連する問題