Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could I Embedded Video in a UIView like Path?

Tags:

path

ios

video

enter image description here

the picture is snapped from Path App, u can see, In the table view,there is a video clip, when I touched on the play button, the video plays without changing to full screen.

it seems the video is Embedded in the table view?

How to do this? could u give a example? thanks

like image 504
lingzhao Avatar asked Dec 20 '22 20:12

lingzhao


2 Answers

Taken from one of my projects, just adjust this 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];
like image 170
jimpic Avatar answered Dec 26 '22 16:12

jimpic


Use HTML5 in UIWebView for video playing as intial is poster image and on click video starts as per your requirement.

Refer this link to play video in webView.

Hope its helpful!

like image 30
Paresh Navadiya Avatar answered Dec 26 '22 16:12

Paresh Navadiya