Call another URL at the time of one video playing from url on iphone
In my application i'm playing 2 videos from array one after another.I want to hit another url at the time of first video begin to play without affecting the video playing.
Here is my code what i have tried for playing two videos one after another,
-(IBAction)playMovie:(id)sender{
i=0;
array=[[NSArray alloc] initWithObjects:@"https://s3.amazonaws.com/adplayer/colgate.mp4",@"https://s3.amazonaws.com/ventuno-platform-flv-sep2010/happy_family.mp4",nil];
[self initializPlayer]; }
The above action event is called when user click on the button to start playing the videos.
-(void)initializPlayer{
if(i<[array count])
i +=1;
else {
i = 1;
}
NSLog(@"i value:%@",[array objectAtIndex:i-1]);
NSURL *url1=[NSURL URLWithString:[array objectAtIndex:i-1]];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:url1];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerPlaybackStateDidChange:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:moviePlayerController];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen=YES;
[moviePlayerController play];}
In initializPlayer method two videos are playing one after another, and also two notifications are there,first one is used to notify when the video completed or user press the done button.another one is used to notify,
1.videoplay 2.videopause 3.video Interrupted 4.videoforward 5.videobackward
-(void)moviePlaybackComplete:(NSNotification *)notification{
NSLog(@"moviePlaybackComplete");
MPMoviePlayerController *moviePlayerController=[notificat开发者_StackOverflow中文版ion object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[moviePlayerController.view removeFromSuperview];
[moviePlayerController release];
[self initializPlayer];}
moviePlaybackComplete notification is used to notify the user when the video is completed.
-(void) moviePlayerPlaybackStateDidChange:(NSNotification*)notification {
NSLog(@"moviePlayerPlaybackStateDidChange");
MPMoviePlayerController *moviePlayer = notification.object;
MPMoviePlaybackState playbackState = moviePlayer.playbackState;
if(playbackState == MPMoviePlaybackStateStopped)
{
//NSLog(@"MPMoviePlaybackStateStopped");
}
if(playbackState == MPMoviePlaybackStatePlaying)
{
//NSLog(@"MPMoviePlaybackStatePlaying");
}
if(playbackState == MPMoviePlaybackStatePaused)
{
//NSLog(@"MPMoviePlaybackStatePaused");
}
if(playbackState == MPMoviePlaybackStateInterrupted)
{
NSLog(@"MPMoviePlaybackStateInterrupted");
}
if(playbackState == MPMoviePlaybackStateSeekingForward)
{
NSLog(@"MPMoviePlaybackStateSeekingForward");
}
if(playbackState == MPMoviePlaybackStateSeekingBackward)
{
NSLog(@"MPMoviePlaybackStateSeekingBackward********");
}}
moviePlayerPlaybackStateDidChange notification is used to notify the user if any changes is made in playbackstate.
MY DOUBT:
At the time of first video playing(beginning) i want to hit another url without affecting the video.Hit one more url at the end of the first video.
Please Guide me to do this.
Thank you
精彩评论