iPhone Video Rotationn - iphone

I'm using the UIIMagePickerController for video capture but after the capture I publish it on our servers and it turns out that the video is not properly oriented. But this problem only occurs when the user take's video in Portrait mode in LandScape Mode everything is simply fine.
Is there any way in which I can detect in which mode video was captured and How can i rotate the video before publish so that everything works fine.

Well, you can query the UIDevice for #property UIDeviceOrientation orientation, and let the server know if the video was captured in landscape or portrait.
You can use one of the helpful UIDeviceOrientationIsLandscape macro to do this.
To query for current orientation, just do
[UIDevice currentDevice].orientation
but watch out: (from UIDevice documentation) The value of this property always returns 0 unless orientation notifications have been enabled by calling beginGeneratingDeviceOrientationNotifications.

Related

Play video on landscape and force app return to portrait

I used MPMoviePlayerViewController to play a video and when back to app, I need app force return portrait
I think the best way to solve this is by using
https://stackoverflow.com/a/13800907/620197
These are callbacks who only gets called when the user autorotates - you can tell the user to rotate the device and then the autorotate callback will be called and will show only the supported orientation.
If you still want force rotation i believe you need to dismiss the controller - try this and please do tell me if it worked out for you:
IOS 6 force device orientation to landscape
I have searched the web for a long time for a force rotation solution that will please me with no success, it almost looks like apple
Doesnt want us to be able to so this.

UIWebView - YouTube Video Landscape mode - iOS6

I want to play a YouTube Video in a UIWebView in fullscreen (Landscape mode)
But all my other views to be only in Portrait mode. How is it possible that only the YouTube video is in landscape mode?
Do I have to enable the landscape mode in the app targets summary?
Thanks for help! :-)
If your app is using multiple orientations then you need to define them in the Project Target summary. e.g Portrait, Landscape left & Landscape right.
If you are having your device working for iOS5, use the following method(deprecated in iOS6) for rotating to particular orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
If you are having your device working on iOS6. you should use the following methods.
– shouldAutorotate – supportedInterfaceOrientations & – preferredInterfaceOrientationForPresentation
If your app supporting both versions then you could keep the both methods and check if your view controller is responding to the particular method by
if ([self respondsToSelector:#selector(methodToCheck)])
myTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
CGAffineTransform rotate = CGAffineTransformMakeRotation(1.57079633);
[myTableView setTransform:rotate];
self.view = myTableView;
This will also work*
make sure here i have done in tableview

Appliction orientation changes to landscape if I stop a video in landscape

I am working on an application in which I have embedded an iframe on a screen to show the thumbnail of a video from vimeo.com. Every thing is working perfect but when I tap to play the video it invokes iPhone's DEFAULT MOVIE PLAYER and then I rotate my iPhone to landscape and video plays in landscape mode. But if video finishes in landscape mode then the screen (on which I have added the vimeo iframe) also gets rotated in landscape mode. I need to fix it in portrait only but video should play in portrait and landscape both modes.
Thanks!
Put this method in your all view controller to force them to remain always in portrait mode
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
When we play a video in this way then iPhone's in built video player get invoked that is of class "mpinlinevideoviewcontroller". We can't control it's functionality. So I set
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
in the view controller containing the web view and now only this screen of the application supports all orientation and thus my issue got removed (but not resolved).
one possible way is : When your player stopped playing just call this function.
-(void)setupOrientaion
{
[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
}
or else post your code here. it 'll be more helpful to analyze.

Why can't I retrieve UIDeviceOrientation correctly while playing a movie in MPMoviePlayerController?

Everything works fine while I'm not playing anything (I'm calling beginnotifications, etc, and using the orientation to rotate my view). But after I start playing with MPMoviePlayerController everytime when I try
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
The orientation gets a UIDeviceOrientationUnknown.
Any clue?
When the movie stops everything works alright again.
I need this orientation to rotate the player's window, because Im using Iphone OS 3.1 so I can't directly use the view property inside MPMovie player controller.
I haven't found a way to do this at least in iPhone OS version lower than 3.2. I gave up.
But hey, I had to code a version for my app in the Ipad and I discovered that for iPhone OS 3.2, there's a way to do it.
The only thing you have to do is to use a custom class, that you have to make child of MPMoviePlayerViewController and override the method shouldAutorotateToInterfaceOrientation to return yes whenever you want the autorotation to be performed. It's all in the MPMoviePlayerViewController class reference.
– Zelldweller

iPad Orientation Lock Notification?

Is there a way to receive a notification when the iPad gets orientation locked? When the orientation lock is set on or off, it does send a receivedRotate: notification, but I need a way to be able to distinguish normal rotations from lock "rotations".
The problem is I am rotating things in my view when the rotation changes. When the lock is activated, the iPad sends a receivedRotate: with UIInterfaceOrientationPortrait.
I've looked in UIDevice for something like isOrientationLocked, but with no success.
Thanks for any clues on this.
EDIT: When the iPad orientation lock is switched ON, it does send a notification that the rotation changed to portrait for some reason. This causes the elements to rotate since they rotate with any orientation change. This is what I want to prevent.
EDIT2: Yes, the iPad shouldn't send a portrait notification but it does. After this portrait notification the iPad stops sending notifications, which is the way it should be. It's just the initial notification that is in the way.
I cannot use the accelerometer because I still want to be able to use the orientation lock's locking feature. Maybe I would use the accelerometer if I had some way of knowing when the iPad was locked.
EDIT3: receivedRotate: is called with UIInterfaceOrientationPortrait for all orientations.
Apparently it's working now.
I recently jumped back into my old project after installing the latest XCode & iPhone SDK and I no longer receive UIInterfaceOrientationPortrait when the lock is switched on. Haven't changed my code at all so it must be Apple.
Just to be clear, are you only using the rotation notifications to determine your rotations? You are not pulling data from the accelerometer or the like to get your orientation?
One other thing is that the lock is just that, a lock, it should not force you into portrait mode if you are in landscape. It should just keep you in landscape.
So, guessing from what you are doing I might suggest that you really do not want to be using the notifications as the basis of your interface but rather the accelerometer data directly.
As a newly minted iPad owner I might wonder what you are doing since I see the lock as a way to keep the orientation the way I want when my physical orientation is not "normal" like laying on the couch.