iphone - Play 2 videos from url one after another -
in application want play 2 url videos 1 after another.
this code:
`- (void)viewdidload {
nslog(@"viewdidload"); player = [[mpmovieplayercontroller alloc] initwithcontenturl:[self movieurl]]; [nsnotificationcenter defaultcenter]addobserver:self selector:@selector(moviefinishedcallback:) name:mpmovieplayerplaybackdidfinishnotification object:player]; [player play];
[super viedidload]; }
- (nsurl *)movieurl { return [nsurl urlwithstring: @"https://s3.amazonaws.com/adplayer/colgate.mp4"];//first video url after video complete.i want play next url video.
}
- (void) moviefinishedcallback:(nsnotification*) anotification { nslog(@"moviefinishedcallback"); player = [anotification object]; [[nsnotificationcenter defaultcenter] removeobserver:self name:mpmovieplayerplaybackdidfinishnotification object:player]; [player autorelease];
}
`
after 1 url video completed want play next url video.
please me.
i have store url's in array this,
array=[[nsarray alloc] initwithobjects:@"https://s3.amazonaws.com/adplayer/colgate.mp4",@"https://s3.amazonaws.com/ventuno-platform-flv-sep2010/happy_family.mp4",nil];
then how can retrive url in - (void) moviefinishedcallback:(nsnotification*) anotification {
}method.please give me guidance in this.
i have not tested it, should work, might need modify little bit. @ least, have idea, how can done
-(void)viewdidload { [self initializplayer]; } static int i; -(void)initializplayer { if(i<=[arrmovieurl count]) +=1; else { = 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 play next video [self initializplayer]; }
Comments
Post a Comment