views:

1819

answers:

5

OK. Some New Query Here.


Suppose user taps on a button & video begins to play. Now when video plays, it always in full screen mode.

But what do i need is explained below.

Video should be played in a portrait mode. (but normally video is played in landscape mode ).

How?


Thanks in advance for sharing your knowledge with SO...

+1  A: 

From the documented docs i do not think this is possible using the built in media player

Daniel
Can we create Custom Media Player?
sugar
good luck with that :)
Daniel
OK. HERE MY requirement is just to play video in portrait mode. Check out my New edited question.
sugar
Sir - Check out my answer. it works for my application.
sugar
Cool, i think thats new to 3.1?
Daniel
Please try new MPMoviePlayerController , available in iPhone SDK 3.2+, which allows u to customize, set required size and also change orientation.
RVN
+1  A: 

Try this out. I found something new.

@interface MPMoviePlayerController (extend)
-(void)setOrientation:(int)orientation animated:(BOOL)value;
@end

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieUR];
[moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO];
if (moviePlayer)
{
 [self.moviePlayer play];
}
sugar
+2  A: 
@interface MPMoviePlayerController (extend) 
 -(void)setOrientation:(int)orientation animated:(BOOL)value; 
@end 

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieUR]; 
[moviePlayer setOrientation:UIDeviceOrientationPortrait animated:NO]; 
if (moviePlayer) 
{ 
    [self.moviePlayer play]; 
} 

This Solution will be rejected by Apple, as setOrientation for movie player is the Private API. You need to be careful, but it may work on Jailbroke iPhones.

RVN
+3  A: 

Just an update, the latest iPhone SDK 3.2+ will now allow the programmers to show the video in any desired size and Orientation, New MPMoviePlayerView is provided, which is a property of MPMoviePlayerController, this view will have the video, which u can add as a subview to your view.

Hope this helps.

Thanks

RVN
+1  A: 

Here's what I did. Add NSNotification to notify you when preloading of the video finishes.

- (void)playVideoUrl:(NSString *)videoUrl {
    NSURL *url = [NSURL URLWithString:videoUrl];
    MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc]   
             initWithContentURL:url]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 

    //MPMoviePlayerContentPreloadDidFinishNotification
    [[NSNotificationCenter defaultCenter] addObserver:self                           
                       selector:@selector(myMovieFinishedPreloading:)                                            
                           name:MPMoviePlayerContentPreloadDidFinishNotification                                                
                         object:theMovie]; 


    // Movie playback is asynchronous, so this method returns immediately. 
    [theMovie play]; 
     }

Callback selector:

-(void)myMovieFinishedPreloading:(NSNotification*)aNotification  {
    NSArray *windows = [[UIApplication sharedApplication] windows];

    UIWindow *moviePlayerWindow = nil;
    if ([windows count] > 1) 
    {
        moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
    }

    CGAffineTransform transform = CGAffineTransformMakeScale(0.5, 0.5);
    transform = CGAffineTransformRotate(transform, -90.0f*M_PI/180.0f);
    [moviePlayerWindow setTransform:transform];

 }
chalcopyrite