Hello All,
I want to play video on iPad + external output (both at same time as youtube does). Currently I am using MPMoviePlayerController class to play videos, but when I create two instances of it only one works. Here is the code -
MPMoviePlayerController * playerViewController = [[MPMoviePlayerController alloc] initWithContentURL:url];
MPMoviePlayerController * playerViewControllerES = [[MPMoviePlayerController alloc] initWithContentURL:url];
/* adding movie to external screen */
if ([[UIScreen screens] count] > 1) {
externalScreen = [[[UIScreen screens] objectAtIndex:1] retain];
screenModes = [externalScreen.availableModes retain];
int screenResCounter = -1;
for (UIScreenMode *mode in screenModes) {
screenResCounter++;
CGSize modeScreenSize = mode.size;
[playerViewControllerES.view setFrame:CGRectMake(-1.0f, -20.0f, modeScreenSize.width, modeScreenSize.height)];
}
UIScreenMode *desiredMode = [screenModes objectAtIndex:screenResCounter];
//[self log:[NSString stringWithFormat:@"Setting mode: %@", desiredMode]];
externalScreen.currentMode = desiredMode;
//[self log:@"Assigning externalWindow to externalScreen."];
externalWindow.screen = externalScreen;
[screenModes release];
[externalScreen release];
CGRect rect = CGRectZero;
rect.size = desiredMode.size;
externalWindow.frame = rect;
externalWindow.clipsToBounds = YES;
[external_screen_view addSubview:playerViewControllerES.view];
externalWindow.hidden = NO;
[externalWindow makeKeyAndVisible];
}
/* adding movie to iPad screen */
if ([currentOrientation isEqualToString:@"lt"])
[playerViewController.view setFrame:CGRectMake(-1.0f, -20.0f, 1025.0f, 788.0f)];
else
[playerViewController.view setFrame:CGRectMake(-1.0f, -20.0f, 769.0f, 1044.0f)];
[self.view addSubview:playerViewControllerES.view];
//---play movie---
[playerViewController play];
[playerViewControllerES play];
I think the problem with multiple instances of the MPMoviePlayerController.
Please help!
Thanks