Embedded video in UIView with iPhone

I would like to write an application that downloads (or transmits) video (encoded as needed) in the form. I do not want to use MPVideoPlayer from the SDK as it opens the video in full screen. I would like to place another UIView (transparent) over the video so that my users can annotate the video.

Does anyone have an idea or could point to some code that will play the video in a UIView?

+2
source share
4 answers

If you want to do this, you will need to enable your own (software) video decoder, which will not have access to hardware accelerations in the system. Even if you can make it work with acceptable performance, it will be a huge drain on the battery.

+1
source

If you want to play the video in portrait mode, I have a solution for this.

If you think -MPMovie Player might work under a view, in my opinion this is not possible.

MP Movie player will work as developed by Apple.

So, the MP Movie player always / almost works in full screen mode.

Solution for portrait mode.

@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];
}

Hope this helps you.

Look, My question is very similar to yours.

playing video on a custom size screen - view on iphone

+1

:

UIViewController *v = [[UIViewController alloc] init];
v.view.backgroundColor = [UIColor orangeColor];

NSString *path = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"mp4"];    
if (![[NSFileManager defaultManager] fileExistsAtPath:path])
{
    NSLog(@"cannot find %@ in bundle or doctuments", path);
}

NSURL *url = [NSURL fileURLWithPath:path];


MoviePlayerViewController *mpvc = [[MoviePlayerViewController alloc] initWithContentURL:url];

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(movieFinishedCallback:) 
                                             name:MPMoviePlayerPlaybackDidFinishNotification 
                                           object:mpvc.moviePlayer];

mpvc.moviePlayer.fullscreen = NO;  
[mpvc.moviePlayer setControlStyle:MPMovieControlStyleNone];
mpvc.moviePlayer.view.frame = CGRectMake(10, 100, 300, 300);

[v.view addSubview:mpvc.moviePlayer.view];
[mpvc.moviePlayer play];

[self presentModalViewController:v animated:YES];

[v release];
+1

Maybe you should check MediaPlayer’s personal headers and just add a video preview as your presentation.

0
source

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


All Articles