Hide MPMoviePlayerController when uploading new videos

I have an iPad app that has 4 buttons on the left side, which corresponds to 4 different video clips. When a user selects the video that they want to see, it appears on the right side. I want it to seem downloadable (as if it was broadcast over the Internet). I added the UIActivityIndicator identifier to the center of the black video frame and set the stream to stop for 3 seconds. However, the player containing the previous video does not disappear. It just freezes in the last frame of the previous video for 3 seconds (hides the activity indicator), and then a new video appears.

Any ideas on how to make the player temporarily hide? Thanks for any help. Here is my code:

-(IBAction) videoButton1{
   [player stop];
   [player release];

   [self.activityIndicator startAnimating];

   NSString *url = [[NSBundle mainBundle] pathForResource:@"video1" ofType:@"mov"];
   [self setupVideoPlayer:url];
}

-(void) setupVideoPlayer: (NSString *) url{
   player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url)];
   player.view.frame = CGRectMake(487, 205, 478, 320);

   [self.view addSubview:player.view];

   [NSThread sleepForTimeInterval:3.0];
   self.activityIndicator stopAnimating];

   [player play];
}
+3
1

, IB , , CGRectMake .

self.player.view.frame = self.viewForMovie.bounds;

self.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

"videoButton1" 0

viewForMovie.alpha = 0;

"setupVideoPlayer" 1.

+2

Source: https://habr.com/ru/post/1778365/


All Articles