IOS – video playback after a few seconds

I want to use MPMoviePlayerController to play a video in UIView.
After pressing the UIButton, the video appears and starts to play.
Unfortunately, after 3-4 seconds, the video changes Black, the audio is still playing.
Any ideas?
Thank you for all your time.

(Using Xcode 4.2.1)

-(void) playMovieButtonPressed:(UIButton*) button{

NSString* video = @"testmovie.m4v";

NSString *filepath = [[NSBundle mainBundle] pathForResource: ofType:];
NSURL * fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController* player = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];


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

player.movieSourceType = MPMovieSourceTypeFile;
[player.view setFrame:CGRectMake (20, 400, 300, 200)];
[self.view addSubview:player.view];
[player prepareToPlay];
[player play];
}

- (void) moviePlaybackComplete:(NSNotification*) notification {
NSLog(@"videoviewcontroller complete: %@", notification);

MPMoviePlayerController *mymoviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:mymoviePlayerController ];
}

I talked to an Apple engineer. The solution is The player must be an instance variable or attribute of the view controller. So it can still be accessed when the view is removed.

-(void) playMovieButtonPressed:(UIButton* ) button{

NSString* video = @"testmovie.m4v";

NSString *filepath = [[NSBundle mainBundle] pathForResource: ofType:];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
self.moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

// .....
}

I want to use MPMoviePlayerController to play a video in a UIView.
After pressing the UIButton, the video appears and starts to play.
Unfortunately, after 3-4 seconds, the video turns black and the audio is still playing. < br>Any ideas?
Thank you for all your time.

(Using Xcode 4.2.1)

-(void) playMovieButtonPressed:(UIButton*) button{

NSString* video = @"testmovie.m4v";

NSString *filepath = [[NSBundle mainBundle] pathForResource: ofType:];
NSURL * fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController* player = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];


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

player.movieSourceType = MPMovieSourceTypeFile;
[player.view setFrame:CGRectMake (20, 400, 300, 200)];
[self.view addSubview:player.view];
[ player prepareToPlay];
[player play];
}

- (void) moviePlaybackComplete:(NSNotification*) notification {
NSLog(@"videoviewcontroller complete:% @", notification);

MPMoviePlayerController *mymoviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:mymoviePlayerController] ;
)

I talked to an Apple engineer. The solution is that the player must be an instance variable or attribute of the view controller. So it can still be accessed when the view is removed.

-(void) playMovieButtonPressed:(UIButton*) button{

NSString* video = @"testmovie.m4v";

NSString *filepath = [[NSBundle mainBundle] pathForResource: ofType:];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
self.moviePlayerController = [[MPMoviePlaye rController alloc] initWithContentURL:fileURL];

// .....
}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3912 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.