Playing a video file from server in an Iphone app

Basically , I get a url from webserver.I want to play a movie file from that url in an iPhone app.Please help! i mean to say my movie file is stored on webserver


This is the common way to play video file from server or from local path.


MPMoviePlayerController *player =[[MPMoviePlayerController alloc] initWithContentURL: myURL];
[[player view] setFrame: [myView bounds]];  // frame must match parent view
[myView addSubview: [player view]];
[player play];

You can do using html5's video tag(provided you are using UIWebView).


- (void)viewDidLoad {
    [super viewDidLoad];

    //to play from actual server location
    //[self playVideo:@"file://localhost/Users/PlayVideos/3idiots.mov" frame:CGRectMake(20, 70, 280, 250)];

        //from server (http://www.example.com/video.mov)..... http://www.ebookfrenzy.com/ios_book/movie/movie.mov
    [self playVideo:@"your server URL" frame:CGRectMake(20, 70, 280, 250)];
}

- (void)playVideo:(NSString *)urlString frame:(CGRect)frame {
    NSString *embedHTML = @"\
    <html><head>\
    <style type=\"text/css\">\
    body {\
    background-color: transparent;\
    color: white;\
    }\
    </style>\
    <script>\
    function load(){document.getElementById(\"yt\").play();}\
    </script>\
    </head><body onload=\"load()\"style=\"margin:0\">\
    <video id=\"yt\" src=\"%@\" \
    width=\"%0.0f\" height=\"%0.0f\" autoplay controls></video>\
    </body></html>";
    NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
    UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
    [videoView loadHTMLString:html baseURL:nil];
    [self.view addSubview:videoView];
    [videoView release];
    NSLog(@"%@",html);
}

playing video from webserver from a url

viewDidLoad{
movieURL=[NSURL URLWithString:@"http://www.samkeeneinteractivedesign.com/videos/littleVid3.mp4"];


moviePlayer =  [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
if ([moviePlayer respondsToSelector:@selector(loadState)]) 
{
    // Set movie player layout
    [moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
    [moviePlayer setFullscreen:YES];
    //  moviePlayer.view.frame = CGRectMake(10,10,1024,760);
    // May help to reduce latency
    [moviePlayer prepareToPlay];
}
}