Search code examples
iosmpmovieplayercontroller

ios MPMoviePlayerController playing video over window


In my iPad application, I want to have back ground animation all over app. So what I did is create the player object and adding it to window in app delegate. And then I made the background color of all the view controller's as clearColor. The following is the code that I wrote. But a small problem is that, my app works only in landscape. Using below code, its adding the video in portrait mode. How can I make it work in iOS 5 and iOS 6?

NSString *filepath   =   [[NSBundle mainBundle] pathForResource:VIDEO_FILE ofType:@"mp4"];
NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];
self.bgPlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
self.bgPlayerController.controlStyle = MPMovieControlStyleNone;
[self.bgPlayerController.view setFrame:CGRectMake(0, 0, 1024, 748)];

[self.window addSubview:self.bgPlayerController.view];
[self.window sendSubviewToBack:self.bgPlayerController.view];

[self.bgPlayerController play];

Also I want to make sure that when the orientation is changed between landscape right and left, the video must also rotate in the background.


Solution

  • I couldn't find any solution. After adding the video to window, i'm manually observing the orientations and rotating the orientation of video by coding.