Playing videos on a custom size screen - view on iphone

OK Some new queries here.


Suppose the user presses a button and starts playing the video. Now that the video is playing, it is always in full screen mode.

But what I need is explained below.

Video should play in portrait mode. (but usually the video plays in landscape mode).

How?


Thank you in advance for sharing knowledge with SO ...

+2
source share
5 answers
@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]; 
} 

Apple, setOrientation - API. , iPhone Jailbroke.

+3

, iPhone SDK 3.2+ , MPMoviePlayerView, MPMoviePlayerController, , u .

, .

+6

From the documented documents, I do not think that this is possible using the built-in media player

+1
source

Try it. I have 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];
}
+1
source

Here is what I did. Add NSNotification to notify you when the video preload is complete.

- (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];

 }
+1
source

Source: https://habr.com/ru/post/1717914/


All Articles