MPMoviePlayerViewController in UIModalPresentationFormSheet Problem - iphone

My problem is that i have a MPMoviePlayerViewController embeded inside a modalviewcontroller that has the formsheet atribute and when the video goes to fullscreen using the pinch or the arrows the controls dont work.
I have figured out that they dont work because only touches inside the rectangle that makes the modalviewcontroller are registered. for example, double tapping to zoom inside the rectangle works while everywhere else it doesnt.
This is a problem since the movie controls can't be used due to this problem. Can anyone help?

Here is how I solved it. I changed the size of the modal view controller when the video was going into fullscreen.
-(void)movieDidEnterFullscreen:(NSNotification *)notification{
NSLog(#"did enter");
self.navigationController.view.superview.frame = CGRectMake(0, 0, 1500,1500);
self.navigationController.view.superview.center = self.view.center;
[mpviewController moviePlayer].controlStyle = MPMovieControlStyleDefault;
}
-(void)movieDidExitFullscreen:(NSNotification *)notification{
NSLog(#"did exit");
UIDevice *device = [UIDevice currentDevice];
[device beginGeneratingDeviceOrientationNotifications];
if (([device orientation] == UIDeviceOrientationLandscapeLeft) || ([device orientation] == UIDeviceOrientationLandscapeRight)){
self.navigationController.view.superview.frame = CGRectMake(0, 0, 620,540);
self.navigationController.view.superview.center = CGPointMake(384, 512);
}
else {
self.navigationController.view.superview.frame = CGRectMake(0, 0, 540,620);
self.navigationController.view.superview.center = CGPointMake(384, 512);
}
[mpviewController moviePlayer].controlStyle = MPMovieControlStyleEmbedded;
}

Related

video rotation using AVMutableVideoCompositionLayerInstruction

I am merging multiple videos and I want to detect which ones are in portrait mode and rotate them in landscape so that all movies are in landscape mode... I have done everything and works perfectly except the actual rotate, I guess it's something with the center of the rotation or a composed rotation.
AVMutableVideoCompositionLayerInstruction *videoTrackLayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:compositionVideoTrack];
if([[AppDelegate sharedInstance] orientationForTrack:avAsset] == UIDeviceOrientationPortrait)
{
CGAffineTransform rotation = CGAffineTransformMakeRotation(M_PI/2);
//CGAffineTransform translateToCenter = CGAffineTransformMakeTranslation(640, 480);
//CGAffineTransform mixedTransform = CGAffineTransformConcat(rotation, translateToCenter);
[videoTrackLayerInstruction setTransform:rotation atTime:nextClipStartTime];
}
else if([[AppDelegate sharedInstance] orientationForTrack:avAsset] == UIDeviceOrientationPortraitUpsideDown)
{
CGAffineTransform rotation = CGAffineTransformMakeRotation(-M_PI/2);
[videoTrackLayerInstruction setTransform:rotation atTime:nextClipStartTime];
}
else if([[AppDelegate sharedInstance] orientationForTrack:avAsset] == UIDeviceOrientationLandscapeLeft)
{
CGAffineTransform rotation = CGAffineTransformMakeRotation(M_PI);
[videoTrackLayerInstruction setTransform:rotation atTime:nextClipStartTime];
}
else if([[AppDelegate sharedInstance] orientationForTrack:avAsset] == UIDeviceOrientationLandscapeRight)
{
[videoTrackLayerInstruction setTransform:CGAffineTransformIdentity atTime:nextClipStartTime];
}
How can I rotate them properly? I have tried multiple sources but nothing rotates them as they should. I am not interested in the 320 scale fit solution I want the video to keep as much resolution as possible before exporting using AVAssetExportSession.
A solution like this:
CGAffineTransform rotationTransform = CGAffineTransformMakeRotation(degreesToRadians(90.0));
CGAffineTransform rotateTranslate = CGAffineTransformTranslate(rotateTransform,320,0);
won't suit my needs as I have tried it. Do you have any ideas? Some help will be pretty much appreciated.

Issues taking pictures with ZBarReader in landscape orientation and flat iPhone position

I'm using ZBar to detect codes but also, I want to enable taking pictures from the same screen. I detected an odd behaviour taking pictures in landscape orientation. If I put my mobile in vertical landscape position the image comes out ok, but If I move my iPhone to the flat landscape position, the picture comes out upside down. I checked UIImage metadata and the image orientation has different values, despite the fact that the device orientation is the same in both cases.
Any idea why this happens?
My solution is to change the image orientation metadata in the wrong cases:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[....]
UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage];
if(image){
// This fixes a bug in ZBarReader taking picture in landscape orientation and device in flat position.
NSLog(#"Image: %d, Device: %d",image.imageOrientation,self.interfaceOrientation);
UIImageOrientation imgOrientation = image.imageOrientation;
UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft && imgOrientation == UIImageOrientationUp){
image = [UIImage imageWithCGImage:[image CGImage] scale:1.0 orientation:UIImageOrientationDown];
}else if(interfaceOrientation == UIInterfaceOrientationLandscapeRight && imgOrientation == UIImageOrientationDown){
image = [UIImage imageWithCGImage:[image CGImage] scale:1.0 orientation:UIImageOrientationUp];
}
[self hideScanner];
[self performSegueWithIdentifier:#"mySegue" sender:image];
}
}
}
}

Camera overlayview not change landscape orientation(Left and Right) in iPhone4?

I have customized the camera with custom buttons(UIButton) by overlay view. My iPhone application will run only in Landscape mode(Left and Right). Now, my camera overlay view change it's orientation left and right perfectly in iPhone 3GS but not run clearly in iPhone4. In ios5 if i launch the camera with overlay view in landscapemode(Right/Left) it launching perfectly but, if i change the orientation to (Right -> Left / Left -> Right) the overlay view not changing perfectly the frame size of the UIView(CameraOverlayView),UIButton frame sizes are changing. How can i fix it? Please help me to fix this problem. I hope you my friends fix my problem. Thanks in advance. Here i have attached my code that i used.
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if(orientation == UIDeviceOrientationLandscapeLeft)
{
CGAffineTransform transform = self.view.transform;
transform = CGAffineTransformRotate(transform, (M_PI / 2.0));
imgpicker.cameraOverlayView.transform = transform;
NSLog(#"Orientation Landscape Left");
}
else if(orientation == UIDeviceOrientationLandscapeRight)
{
imgpicker.cameraOverlayView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, 117.81);
NSLog(#"Orientation Landscape Right");
}
This code works good in iPhone#GS(ios4) but not working good in iPhone4(ios5). Can anyone please help me to fix this problem?
Thank you my friends. I have solved this issue by myself. I just set the bounds to UIView so it covers full view on Camera OverlayView and also i have tried above code that i mentioned in my question.
cameraview.bounds = CGRectMake(0.0, 0.0, 480.0f, 320.0f);
And so i have checked this code at beginning of Camera launch,
UIInterfaceOrientation orientation= [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeLeft)
{
imgpicker.cameraOverlayView.transform = CGAffineTransformRotate(CGAffineTransformIdentity,117.81);
}
else if (orientation == UIInterfaceOrientationLandscapeRight)
{
CGAffineTransform transform = self.view.transform;
transform = CGAffineTransformRotate(transform, (M_PI/2.0));
imgpicker.cameraOverlayView.transform = transform;
}
After this i was check this condition in UIDeviceOrientation Notification also. Now, my app working charm. Thanks.

How to avoid text disappearing when using CGAffineTransform?

I want to make a button rotate in my app, and I have the following piece of code:
- (void)setFrameForButton:(UIButton *)ok {
if ([[UIDevice currentDevice] isWildcat]) {
if([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
ok.frame = CGRectMake(244, 840, 280, 20);
if (wasChanging) ok.transform = CGAffineTransformMakeRotation(M_PI * -0.50);
}
else {
ok.frame = CGRectMake(372, 584, 280, 20);
if (wasChanging) ok.transform = CGAffineTransformMakeRotation(M_PI * -0.50);
}
}
else {
ok.frame = CGRectMake(15.0, 375.0 ,280.0, 20.0);
}
if (wasChanging) wasChanging = NO;
}
- (void)window:(id)window willRotateToInterfaceOrientation:(int)orientation duration:(double)duration {
wasChanging = YES;
[self setFrameForButton:btn];
}
Although when I rotate the position it should be is changed and after some following rotations the text at my button disappears. What to do?
Not sure whether this is the issue, but try setting the autoresizesSubviews property of yor UIButton to NO. This might stop the UIButton from trying to transform its text in any weird way and mess it up.

iPhone Cocos2d game change to iPad game

I have spent 1000's of hours into one of my games and just started looking at iPad stuff. Yeah... didn't realize what the whole CGSize size = [[CCDirector sharedDirector] winSize]; thing was until now.
So I'm pretty much screwed right? There's no sense in changing literally 10,000 ccp coordinates?
Is there a way:
if iPad
add or subtract to the ccp to position to put everything in the center
I could add it to every scene.
Yes no worries. I believe you just need to change your assets and just define:
float deviceScale
And you can easily check in your appDelegate, what device is the program running on:
NSString *deviceType = [UIDevice currentDevice].model;
NSLog(#"deive name is %#",deviceType);
if([deviceType isEqualToString:#"iPad"] || [deviceType isEqualToString:#"iPad Simulator"] ){
[[CCDirector sharedDirector] setContentScaleFactor:1];
} else {
if([[UIScreen mainScreen] respondsToSelector:NSSelectorFromString(#"scale")])
{
if ([[UIScreen mainScreen] scale] < 1.1){
[[CCDirector sharedDirector] setContentScaleFactor:1];
}
if ([[UIScreen mainScreen] scale] > 1.9){
//retina display
[[CCDirector sharedDirector] setContentScaleFactor:2];
}
}
else {
[[CCDirector sharedDirector] setContentScaleFactor:1];
}
}
As I said before you might need to have a variable 'deviceScale', for retina/ ipad make it deviceScale = 1 for all others deviceScale = 0.5. Then scale down the images if device is non retina or not ipad.
I hope your app is using version 0.99.5. 0.99.5 is using by pixels or something.. So you wont b screwed. It will auto scale by ratio.. No worries..