How could I embed a video in a UIView as a path?

enter image description here

The picture was taken from the Path app, you can see. There is a video clip in the table view, when I touched the play button, the video plays without changing to full screen.

Does the video seem to fit in a table view?

How to do it? could give an example? thanks

+4
source share
2 answers

Taken from one of my projects, just adjust it to fit your needs:

NSURL *movieUrl = [NSURL fileURLWithPath:moviePath]; MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieUrl]; player.view.frame = CGRectMake(0, 0, 690, 370); // Here is where you set the control Style like fullscreen or embedded player.controlStyle = MPMovieControlStyleDefault; //player.controlStyle = MPMovieControlStyleEmbedded; //player.controlStyle = MPMovieControlStyleDefault; //player.controlStyle = MPMovieControlStyleFullscreen; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinished) name:MPMoviePlayerPlaybackDidFinishNotification object:player]; UIView *movieBox = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 600, 400)]; [movieBox setBackgroundColor:[UIColor blackColor]]; [movieBox addSubview:player.view]; [self.view addSubview:movieBox]; player.scalingMode = MPMovieScalingModeAspectFit; player.contentURL = movieUrl; [player play]; 
+9
source

Use HTML5 in UIWebView to play videos, since intial is an image of a poster, and click-to-click starts according to your requirement.

Refer to this for video playback in webView.

Hope this will be helpful!

+3
source

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


All Articles